首页 > 解决方案 > 使用 OneDrive (NodeJS) 上传文件期间访问被拒绝

问题描述

我目前正在尝试将我的文件上传OneDrive

我一直在关注 OneDrive Graph文档和 Tanaike 的示例

我能够创建一个上传会话,但是当我尝试将字节上传到上传会话时,我得到了

function uploadFile(uploadUrl, context) { // Here, it uploads the file by every chunk.
    asy.eachSeries(getparams(), function(st, callback){
        setTimeout(function() {
            fs.readFile(file, function read(e, f) {
                context.log(st.cr);
                //context.log(st.clen);
                request.put({
                    url: uploadUrl,
                    headers: {
                        //'Content-Length': st.clen,
                        'Content-Range': st.cr,
                    },
                    body: f.slice(st.bstart, st.bend + 1),
                }, function(er, re, bo) {
                    if(er){
                        context.log('   Upload Error' + bo);
                    }
                    else{
                        context.log('   ERROR HERE: ' + bo);
                        context.res = {
                            // status: 200, /* Defaults to 200 */
                            headers: {'Content-Type': 'application/json'},  
                            body: bo
                        };
                    }
                });
            });
            callback();
        }, st.stime);
    });
}

来自 PUT 请求的响应:

"error":{"code":"accessDenied","message":"The caller does not have permission to perform the action."}

我已经检查并确定我是该文件夹的所有者。我做了很多谷歌搜索,但我无法找到我是如何被拒绝的。

我也在邮递员上试过,同样的错误。我离开了 Authorization Header 字段,并且

标题

Content-Range:bytes 0-4019880/4019881
Content-Type:application/x-www-form-urlencoded

以前试过这个的人可以指导我吗?

标签: node.jsmicrosoft-graph-apionedrive

解决方案


推荐阅读