Managing assets
Uploading new files
Upload Image + Document + Audio
To upload documents, photos or audio files send a request to POST /assets
endpoint and add source
field type (multipart/form-data).
{
"source": {Multipart/form-data}
}
Upload Video
Upload videos as chunks, handle errors and resume the upload of any remaining chunks. There are three different upload phases:
1. Start - Initialize an upload session
Start a resumable upload by initializing a new asset object. To make a start request and
create a video upload session, send a request to POST /assets
endpoint, set the upload_phase
field to start
,
and specify file_size
, in bytes.
{
"label": "Video",
"upload_phase": "start",
"file_size": "8308859"
}
2. Transfer - Upload chunks
Once you have chunks ready to upload with the right start_offset and end_offset you can make a transfer request to upload the chunk, and get the offset for the next chunk.
Split the video with the UNIX command split -b{X}m {filename}
. This command splits your file into multiple parts of X MB each.
To upload the first video chunk, send a request to the POST /assets/{id}/multipart
endpoint and set the upload_phase
field to transfer and add file_chunk
(multipart/form-data).
The default chunk size is 52428800
bytes.
{
"upload_phase": "transfer",
"original_name": "1c5b89d9-b6cc-4962-90c8-766769a478aa_1080.mp4",
"file_chunk": // File Upload Chunk.
}
3. Finish - Post the video
Once you upload all chunks, make a finish request to complete the upload, post the video, and queue it for asynchronous video-encoding.
Make a request to POST /assets/{id}/multipart
endpoint with the param upload_phase set to finish.
{
"upload_phase": "finish"
}
Update
To update an existing asset.
PUT: /assets/{id}
Destroy
To destroy an existing asset.
DELETE: /assets/{id}
Scopes
assets
, assets_publish
, assets_delete
Events
asset.created
will be fired when a new asset is created.asset.changed
will be fired when the asset is changed.asset.deleted
will be fired when the asset is deleted.