Austin
Austin

Reputation: 756

Upload File with unknown size OneDrive

So I am uploading a file to one drive using a resumable file upload session. However I cannot know the size of the file before uploading. I know that google allows uploading of files with content ranges like

Content-Range: 0-128/*

I would assume OneDrive would also allow it as it is even specified in RFC2616

Content-Range = "Content-Range" ":" content-range-spec

   content-range-spec      = byte-content-range-spec
   byte-content-range-spec = bytes-unit SP
                             byte-range-resp-spec "/"
                             ( instance-length | "*" )

   byte-range-resp-spec = (first-byte-pos "-" last-byte-pos)
                                  | "*"
   instance-length           = 1*DIGIT

The header SHOULD indicate the total length of the full entity-body, unless this length is unknown or difficult to determine. The asterisk "*" character means that the instance-length is unknown at the time when the response was generated.

But after reading the OneDrive documentation I found it says

Example: In this example, the app is uploading the first 26 bytes of a 128 byte file.

The Content-Length header specifies the size of the current request.

The Content-Range header indicates the range of bytes in the overall file that this request represents.

The total length of the file is known before you can upload the first fragment of the file. HTTP

Copy PUT https://sn3302.up.1drv.com/up/fe6987415ace7X4e1eF866337
Content-Length: 26 Content-Range: bytes 0-25/128

<bytes 0-25 of the file>

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.

Maybe I'm just reading the documentation wrong or it only applies to this example but before I go and build a entire uploader I would just like clarification if this is allowed for OneDrive

My Question is

Does OneDrive allow uploading of files with unknown sizes?

Thanks in advance for your help

Upvotes: 1

Views: 390

Answers (1)

Austin
Austin

Reputation: 756

For anyone else wondering, no you can't, file uploads must specify a size.

Upvotes: 1

Related Questions