Resumable Upload API
This article demonstrates how to use the response object from generateFileResumableUploadUrl()
to upload a file to a site's Media Manager.
Note: Due to limits on the size and duration of files that you can upload, we recommend using importFile()
. See Wix Media: Supported Media File Types and File Sizes for more details.
Authorization
This endpoint uses the uploadToken
from the response for authorization.
No additional authorization is needed.
Syntax
1
Query Params
Name | Type | Optional | Description |
---|---|---|---|
filename | string | no | File name that appears in the Media Manager. Include the file's extension in the name to prevent potential errors. |
Example
Implement a Resumable Upload Client using TUS Protocol
In this example we use tus-js-client to implement a resumable upload using the TUS protocol.
Request
1
Note: Receiving a successful response does not indicate that the upload is complete. To run code when the upload finishes, use the onFileDescriptorFileReady()
and onFileDescriptorFileFailed()
events. Learn more about knowing when a file is ready.
Response
1
Status/Error Codes
Errors from this endpoint will include an HTTP status code.
Use uploaded media on your site
After making the REST HTTP request, you can either display the media on your site directly from the Media Manager, or you can set the uploaded media to $w
elements.
To display the media files on the frontend of your site with code, you first need to retrieve the file's Media Manager URL.
To retrieve the Media Manager URL:
- Call
getFileDescriptor()
, passing infile.id
from the Upload API's response object as its only parameter. - Retrieve the valid Media Manager URL from the
media
property in theFileDescriptor
object that was returned in the previous step. - To use the media in a
$w
element, set the value of the associatedmedia
property to the element'ssrc
property.