Upload API

This article demonstrates how to use the uploadUrl response from Generate File Upload Url 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 Import File. See Wix Media: Supported Media File Types and File Sizes for more details.

Authorization

This method uses the upload token included in the URL for authorization. No additional authorization is needed.

Syntax

Copy

Headers Params

NameTypeOptionalDescription
Content-TypestringnoFile content type. For example, "image/jpeg" for a jpg file.

Note: You can use the standard File API to retrieve the file content type using the File or Blob type attributes. You can also use external libraries, such as file-type, to retrieve the file content type.

Query Params

NameTypeOptionalDescription
filenamestringnoFile 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.

Example

Note: This example uses axios to make an API call, but you can use any HTTP client that allows a payload of binary data. To learn how to install npm packages like axios, see Work with npm Packages in the Editor.

Request

Copy

Note: Receiving a successful response does not indicate that the upload is complete. To run code when the upload finishes, listen for the File Ready and File Failed events. Learn more about knowing when a file is ready.

Response

Copy

Status/Error Codes

Errors from this endpoint will include an HTTP status code.

Did this help?