使用OneDrive Rest API分段上传二进制内容 [英] Multipart upload binary content with OneDrive Rest APIs

查看:333
本文介绍了使用OneDrive Rest API分段上传二进制内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据API文档此处我向邮递员提出了如下要求: .一切正常.

As per the API documentation here I formed my request with postman as follows: . This is working fine.

但是,当涉及二进制内容(以base64格式编码)时,它将上载文件,但是当我尝试在OneDrive上打开该文件时未预览该文件. 文件已成功上传但无法预览.

But when it comes to binary content(encoded in base64 format), it uploads the file but that is not previewed when I try to open the same on OneDrive. File gets uploaded successfully but not previewable.

我在这里想念什么?有什么建议吗?

What am I missing here? Any suggestions?

推荐答案

使用分段上传方法时,OneDrive不支持Content-Transfer-Encoding.在这种情况下,我们将忽略标头(似乎是一个错误),而只是将base64编码的数据存储在文件流中(而无需对其进行解码).

OneDrive doesn't support Content-Transfer-Encoding when using the multi-part upload method. In this case, we're ignoring the header (that seems like a bug) and just storing the base64 encoded data in the file stream (without decoding it).

您必须上载原始字节作为请求的第二部分,而无需任何内容传输编码,以完成这项工作.

You'll have to upload the raw bytes as the second part of the request, without any content-transfer-encoding, to have this work.

由于似乎您只是在上传文件而没有在设置文件时尝试设置任何自定义元数据,所以最好使用其他上传方法之一,例如PUT或createUploadSession

Since it seems like you are just uploading a file and not trying to set any custom metadata while doing it, you're better off using one of the other upload methods, like PUT or createUploadSession

这篇关于使用OneDrive Rest API分段上传二进制内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆