小编Bri*_*ith的帖子

如何为Upload Session Microsoft Graph API格式化Content-Range标头

我遇到了使用v1.0 Microsoft Graph API将文件上传到上传会话的问题.我的步骤:

  1. 获取访问令牌:成功
  2. 选择文件/创建上传会话:成功(我返回uploadUrl上传字节)
  3. 将字节上传到uploadUrl:失败并出现以下错误.

这是我收到的错误:

{
   "error": 
   {
      "code":"invalidRequest",
      "message":"The Content-Range header is missing or malformed."
   }
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下格式,但仍然收到相同的错误.

"bytes 0-100/100"
"0-100/100"
"0-100"
Run Code Online (Sandbox Code Playgroud)

我正在关注Mircosoft的这篇文章https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/item_createuploadsession

这是我的函数,上传到uploadUrl从创建上传会话中检索

public uploadToSession(file: HTMLInputElement, session: any, fileData: any) {
    var headers = new Headers();
    headers.append('Content-Length', fileData.length); //(ie: "100")
    headers.append('Content-Range', fileData.range); //(ie: "bytes 0-100/100")
    this.http.put(session.uploadUrl, { headers })
        .subscribe(
            (res: Response) => console.log(res),
            error => console.log(error)
        );
}
Run Code Online (Sandbox Code Playgroud)

任何帮助深表感谢!提前致谢.

sharepoint typescript microsoft-graph

2
推荐指数
1
解决办法
913
查看次数

标签 统计

microsoft-graph ×1

sharepoint ×1

typescript ×1