Multipart upload binary content with OneDrive Rest

2019-08-19 23:11发布

问题:

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

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?

回答1:

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.

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



回答2:

Drive does not store the image in the base64 format it stores it in binary. you can directly select the image using postman and can upload as binary with the multipart request

Here is the link for adding blob in the postman

How to upload images using postman to azure blob storage