Hi @jthake,
on the link you have posted, it says
Upload bytes to the upload session
To upload the file, or a portion of the file, your app makes a PUT request to the uploadUrl value received in the createUploadSession response. You can upload the entire file, or split the file into multiple byte ranges, as long as the maximum bytes in any given request is less than 60 MiB.
The fragments of the file must be uploaded sequentally in order. Uploading fragments out of order will result in an error.
Note: If your app splits a file into multiple byte ranges, the size of each byte range MUST be a multiple of 320 KiB (327,680 bytes). Using a fragment size that does not divide evenly by 320 KiB will result in errors committing some files.
There are a couple of takeaways from that,
- The max file size in one go or a file fragment is 60MB not 4 MB
- If you split the file into byte ranges, then the size of each byte range is a multiple of 320KB otherwise it will result in an error.
If you do still want to upload the data in fragments, then you will have to do so in a loop, where the first loop will send data as you have above and you wait for a 202, and you ensure that you get a JSON response with the content
{
"expirationDateTime": "2015-01-29T09:21:55.523Z",
"nextExpectedRanges": ["26-"]
}
where the nextExpectedRanges
tells you what you need to send because it can ask for arbitrary ranges like
{
"expirationDateTime": "2015-01-29T09:21:55.523Z",
"nextExpectedRanges": [
"12345-55232",
"77829-99375"
]
}
Most importantly, you would be using the POST
method rather than PUT
cheers,
Jayant