使用OneDrive(NodeJS)上传文件期间访问被拒绝

时间:2018-11-27 09:16:05

标签: node.js microsoft-graph onedrive

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

我一直在关注OneDrive图形docs和Tanaike的example

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

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."}

我已检查并确定我是该文件夹的所有者。 我做了很多谷歌搜索,但是我只是找不到自己被拒绝的方式。

我也曾在邮递员上尝试过,但有相同的错误。 我将“授权标头”字段留在外面,并且

标题

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

任何尝试过此方法的人都可以指导我吗?

0 个答案:

没有答案
相关问题