An API that connects multiple Microsoft services, enabling data access and automation across platforms
Support for Streaming Uploads with Unknown Final Size in Microsoft Graph OneDrive Upload Sessions
Hello Microsoft Graph Team,
We are integrating OneDrive as a storage backend in our application using the Microsoft Graph API (/me/drive) and have encountered a design constraint that we'd like to confirm and, if possible, identify a supported workaround for.
Our Use Case
Our application generates ZIP archives on the server and streams them directly to OneDrive. Since the ZIP archive is produced on the fly, the final file size is not known until the archive generation is complete.
Our goal is to upload the data as it is being generated, without first writing the entire archive to temporary storage.
Current Constraint
We are using an upload session (createUploadSession → chunked PUT requests).
Each chunk upload requires a Content-Range header in the following format:
Content-Range: bytes {start}-{end}/{total}
From our testing, Microsoft Graph rejects requests where {total} is specified as * (unknown) and instead requires the final total file size to be provided from the very first chunk.
As a result, we are forced to:
- Generate the complete ZIP archive.
Store it temporarily.
Measure the final file size.
Start the upload session only after the entire archive has been created.
This prevents us from overlapping archive generation and upload, increasing both latency and temporary storage requirements.
Comparison with Other Storage Services
Other storage APIs provide mechanisms that support streaming uploads without requiring the final size upfront. For example:
Azure Blob Storage allows uploading blocks and specifying the final object only during the commit operation.
WebDAV/Nextcloud chunked uploads similarly allow the total size to be determined only when the upload is finalized.
These approaches enable true producer-to-storage streaming.
Questions
Does the Microsoft Graph upload session support uploading chunks without knowing the total file size in advance?
Is there any supported way to use * (or an equivalent) for the total value in Content-Range?
Can the final size be declared only on the last chunk or during a separate finalize/commit operation?
If not, is there any alternative Microsoft Graph endpoint, upload mechanism, beta feature, or preview API that supports streaming uploads where the total file size is unknown at the beginning?
If neither of the above is supported, could you please confirm whether the officially expected approach is to fully generate and measure the file before initiating the upload session?
We would appreciate clarification on whether this limitation is by design and whether there are any plans to support true streaming uploads in the future.
Thank you for your time and assistance.Subject: Support for Streaming Uploads with Unknown Final Size in Microsoft Graph OneDrive Upload Sessions
Hello Microsoft Graph Team,
We are integrating OneDrive as a storage backend in our application using the Microsoft Graph API (/me/drive) and have encountered a design constraint that we'd like to confirm and, if possible, identify a supported workaround for.
Our Use Case
Our application generates ZIP archives on the server and streams them directly to OneDrive. Since the ZIP archive is produced on the fly, the final file size is not known until the archive generation is complete.
Our goal is to upload the data as it is being generated, without first writing the entire archive to temporary storage.
Current Constraint
We are using an upload session (createUploadSession → chunked PUT requests).
Each chunk upload requires a Content-Range header in the following format:
Content-Range: bytes {start}-{end}/{total}
From our testing, Microsoft Graph rejects requests where {total} is specified as * (unknown) and instead requires the final total file size to be provided from the very first chunk.
As a result, we are forced to:
Generate the complete ZIP archive.
Store it temporarily.
Measure the final file size.
Start the upload session only after the entire archive has been created.
This prevents us from overlapping archive generation and upload, increasing both latency and temporary storage requirements.
Comparison with Other Storage Services
Other storage APIs provide mechanisms that support streaming uploads without requiring the final size upfront. For example:
Azure Blob Storage allows uploading blocks and specifying the final object only during the commit operation.
WebDAV/Nextcloud chunked uploads similarly allow the total size to be determined only when the upload is finalized.
These approaches enable true producer-to-storage streaming.
Questions
Does the Microsoft Graph upload session support uploading chunks without knowing the total file size in advance?
Is there any supported way to use * (or an equivalent) for the total value in Content-Range?
Can the final size be declared only on the last chunk or during a separate finalize/commit operation?
If not, is there any alternative Microsoft Graph endpoint, upload mechanism, beta feature, or preview API that supports streaming uploads where the total file size is unknown at the beginning?
If neither of the above is supported, could you please confirm whether the officially expected approach is to fully generate and measure the file before initiating the upload session?
We would appreciate clarification on whether this limitation is by design and whether there are any plans to support true streaming uploads in the future.
Thank you for your time and assistance.