Is it possible to upload a file to One Drive if I don't know its size ahead of time?

pratik jaiswal 21 Reputation points
2021-04-05T14:17:36.473+00:00

Our application will frequently have the need to upload a stream of bytes for a file to One Drive, and we won't know the size of the file ahead of time. I am aware of the documentation for One Drive here that clearly indicates it is not possible, but I am really hoping if there's a way to work around this.

Important: Your app must ensure the total file size specified in the Content-Range header is the same for all requests. If a byte range declares a different file size, the request will fail.

Or is there any work being done to enhance the REST API so we can do this? Google Drive uses a very similar method for uploading large files, but supports unknown file sizes by doing this with the Content-Range header during chunk transfer 0-127/* and then on the final chunk we can specify the known size 128-255/256.

I'm just really surprised this is not supported.

OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,135 questions
0 comments No comments
{count} votes

Accepted answer
  1. Emi Zhang-MSFT 22,011 Reputation points Microsoft Vendor
    2021-04-06T08:15:56.02+00:00

    Hi @pratik jaiswal ,
    Based on your description, I suggest you try to post this issue to OneDrive for Developer forum:

    https://techcommunity.microsoft.com/t5/onedrive-developer/bd-p/OneDriveDeveloper

    And you can also give a feedback about it to OneDrive UserVoice forum, this is a way for Microsoft collect feedback from users:

    https://onedrive.uservoice.com/

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful