In This Article
Upload API
This article demonstrates how to use the uploadUrl
response from the Generate File Upload Url endpoint to upload a file to a site's Media Manager.
Authorization
This endpoint uses the upload token included in the url for authorization. No additional authorization is needed.
Syntax
Copy
1PUT {{generateFileUploadUrlResponse.uploadUrl}}
Headers Params
Name | Type | Optional | Description |
---|---|---|---|
Content-Type | string | no | File content type. For example, "image/jpeg" for a jpg file. |
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. |
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.
Request
Copy
1async function uploadMyFile(uploadUrl, fileContent) {2 const params = {'filename':'my-audo-track.mp3'};3 const headers = {4 'Content-Type': 'application/octet-stream'5 } 6
7 const uploadResponse = await httpClient.put( uploadUrl, fileContent, { headers, params } );8 return uploadResponse;9}
Response
Copy
1{2 "file": {3 "id": "2acbb8_86485e224dd84143ba2f228777217bb7~mv2.jpeg",4 "displayName": "file.jpg",5 "url": "https://static.wixstatic.com/media/2acbb8_86485e224dd84143ba2f228777217bb7~mv2.jpeg",6 "parentFolderId": "media-root",7 "hash": "cf96f0567ed967f02bc9580ab8db86be",8 "sizeInBytes": "15359",9 "private": false,10 "mediaType": "IMAGE",11 "media": {12 "image": {13 "image": {14 "id": "2acbb8_86485e224dd84143ba2f228777217bb7~mv2.jpeg",15 "url": "https://static.wixstatic.com/media/2acbb8_86485e224dd84143ba2f228777217bb7~mv2.jpeg",16 "height": 226,17 "width": 370,18 "filename": "myfilename.jpg",19 "sizeInBytes": "15359"20 },21 "faces": []22 }23 },24 "operationStatus": "READY",25 "thumbnailUrl": "https://static.wixstatic.com/media/2acbb8_86485e224dd84143ba2f228777217bb7~mv2.jpeg",26 "labels": [],27 "createdDate": "2022-09-11T15:13:24.000Z",28 "updatedDate": "2022-09-11T15:13:24.000Z"29 }30}
Status/Error Codes
The response will include an HTTP status code.
Was this helpful?
Yes
No