我遇到了使用v1.0 Microsoft Graph API将文件上传到上传会话的问题.我的步骤:
这是我收到的错误:
{
"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)
任何帮助深表感谢!提前致谢.