Uploads
The Upload API, available at upload.contentful.com (or upload.eu.contentful.com for EU data residency customers), provides Contentful SDKs with a direct file upload service. You can upload any binary data (including images, videos and text files) and associate the uploaded files with different Assets within a Space.
The Upload API enables the uploading of files to remote storage. To complete an upload, the uploaded file must be associated with an Asset and that asset must be processed. If the association and processing steps are not executed successfully within 24 hours after uploading, the file and its metadata will expire and be deleted from the storage area. The expiration date of the file is indicated in the API response data as expiresAt.
You can associate an Upload resource with more than one Asset and/or locale
Uploading a file
To upload a file, you send a POST request to the create upload endpoint with the binary data in the request body, and include Content-Type: application/octet-stream in the request headers. Depending on the size of your file, a success response may take some time to return. Once the upload finishes, you will receive an Upload resource in the response body.
Associating an upload with an asset
When the upload request is successful you will receive an Upload resource containing an upload_id within the sys.id field that references the uploaded file. You need to use the upload_id to associate the Upload resource with an Asset.
To associate an Upload resource with an Asset, you need to pass upload_id to the asset creation end point of the CMA with the following structure:
Maximum file size
The maximum file size should not exceed 1000MB per uploaded asset. See our Fair Usage Policy for more information. If you try to upload a larger file you will receive a Request Timeout error from the API.
Resumability
The current version of the Upload API doesn’t support resumability. If you encounter an error during the upload process, you need to begin the process from the beginning. It’s the client’s responsibility to take recovery actions in case of an error.
Upload resource
The JSON structure for an Upload has the following structure:
Upload a file
https://upload.contentful.com or https://upload.eu.contentful.com for EU data residency customers.Uploads a file to temporary file storage. Include the binary data you want to send in the request body, and Content-Type: application/octet-stream in the headers.
Retrieving an upload
https://upload.contentful.com or https://upload.eu.contentful.com for EU data residency customers.Retrieves an unmodified image. This is the same URL from an asset’s file.url field, containing the token ids and image name.
Deleting an upload
https://upload.contentful.com or https://upload.eu.contentful.com for EU data residency customers.Deletes a file from temporary data storage and all the metadata associated with the given upload_id.
By default, all uploaded files are automatically deleted after 24 hours starting from when first upload request is issued.