Upload content in chunks
Sometimes you'll need to use the upload-in-chunks method. This is usually the case when files are big and/or expected to fail due to connection issues. Uploading in chunks means that each POST method will POST a part of the file and the last POST will create the file and return all data relevant. If chunk upload fails then the client can try to upload the chunk again. The order of the chunks is not important and the file will be created when the last chunk arrives successfully to the server.
Click here to get the POST URL to upload to your account. To upload an asset directly to a gallery use the upload_url returned from the gallery.list.json command.
When uploading a chunk one must add the following to the POST header :
X-File-Name : this_is_the_file_name.mp4
Content-Range : bytes 10240000-20480000/306519703
Content-Length : 10240000
unique-id : (optional) - GUID or whatever unique string, if you have multiple uploads in the same name (this might happen mostly when testing), better add this to tell the server that those are different uploads.
Each successful chunk upload will return the following, this indicates that the chunk received ok and the client can continue to the next chunk :
authentication ok
chunk done.
Successful POST will return the following for the last chunk, in this case, the new resource ID is AEyCfY7ET4hA :
authentication ok
file received ok
reading metadata ok
file stored ok
creating resource ok
new resource id 196481794 AEyCfY7ET4hA
done.