This article demonstrates how to use the uploadUrl
response from generateFileUploadUrl()
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.
This endpoint uses the upload token included in the url for authorization. No additional authorization is needed.
Name | Type | Optional | Description |
---|---|---|---|
Content-Type | string | no | File content type. For example, "image/jpeg" for a jpg file. |
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. |
Note: In case of failure due to incorrect mimeType
, include the file's extension in the filename
parameter and set the Content-Type
to 'application/octet-stream'. Doing this allows Wix servers to detect the correct content type of the file.
Notes:
onFileDescriptorFileReady()
and onFileDescriptorFileFailed()
events. Learn more about knowing when a file is ready.axios
.
Errors from this endpoint will include an HTTP status code.
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:
getFileDescriptor()
, passing in file.id
from the Upload API's response object as its only parameter.media
property in the FileDescriptor
object that was returned in the previous step.$w
element, set the value of the associated media
property to the element's src
property.