> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # GenerateFileUploadUrl # Package: mediaManager # Namespace: FilesService # Method link: https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/generate-file-upload-url.md ## Permission Scopes: Manage Media Manager: SCOPE.DC-MEDIA.MANAGE-MEDIAMANAGER ## Introduction Generates an upload URL to allow external clients to upload a file to the Media Manager.
Learn how to use the generated upload URL to [upload a file to the Media Manager](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/upload-api.md). > **Notes:** > - When you upload a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about [knowing when a file is ready](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/importing-files.md). > - Any interruption in the upload process stops the file upload. For files larger than 10MB, or when network connection is poor, call Generate File Resumable Upload URL instead. With the resumable upload URL, any interruption in the upload process pauses the file upload, and resumes the file upload process after the interruption. --- ## REST API ### Schema ``` Method: generateFileUploadUrl Description: Generates an upload URL to allow external clients to upload a file to the Media Manager.
Learn how to use the generated upload URL to [upload a file to the Media Manager](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/upload-api.md). > **Notes:** > - When you upload a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about [knowing when a file is ready](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/importing-files.md). > - Any interruption in the upload process stops the file upload. For files larger than 10MB, or when network connection is poor, call Generate File Resumable Upload URL instead. With the resumable upload URL, any interruption in the upload process pauses the file upload, and resumes the file upload process after the interruption. URL: https://www.wixapis.com/site-media/v1/files/generate-upload-url Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: mimeType Method parameters: param name: externalInfo | type: ExternalInfo - name: origin | type: string | description: External information to specify in the File Ready or File Failed events. - name: externalIds | type: array | description: External GUIDs to specify in the File Ready or File Failed events. param name: fileName | type: fileName | description: Temporary file name used to identify the file type. For example, a file named "myFile.jpeg" identifies as an "image/jpeg" file type.
**Notes:** param name: filePath | type: filePath | description: Path to the folder where the file will be stored. For example, `/videos/2024/december`.
If `parentFolderId` is defined, the parent folder is used as the path root. Otherwise, the root is `media-root`. The folders in the path will be created if they don't already exist.
param name: labels | type: array | description: Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images. param name: mimeType | type: mimeType | description: File mime type. | required: true param name: parentFolderId | type: parentFolderId | description: GUID of the file's parent folder.
This folder is the path root for the `filePath`.
Default: `media-root`. param name: private | type: private | description: Whether the file will be public or private. Learn more [about private files](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/private-files.md). param name: sizeInBytes | type: sizeInBytes | description: File size in bytes. Return type: GenerateFileUploadUrlResponse - name: uploadUrl | type: string | description: The URL for uploading a file to the Media Manager. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: SITE_QUOTA_EXCEEDED | Description: Site quota has been exceeded. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FILE_SIZE_OVER_LIMIT | Description: File size exceeds the limit for this media type. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILE_FORMAT | Description: File format is recognized but not supported. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ZERO_FILE_SIZE | Description: File size is 0 bytes. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISMATCH_MIME_TYPE | Description: MIME type doesn't match the file extension. ``` ### Examples ### Generate an upload URL ```curl curl -X POST \ 'https://www.wixapis.com/site-media/v1/files/generate-upload-url' \ -H 'Authorization: ' -H 'Content-Type: application/json' \ --data-binary '{ "mimeType": "image/jpeg", "fileName": "T-shirt.jpg", "sizeInBytes": "2608831" "parentFolderId":"25284aa06584441ea94338fdcfbaba12", "private": false, "labels": ["AMS:external_file_id", "woman", "bicycle"] }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.mediaManager.FilesService.generateFileUploadUrl(mimeType, options) Description: Generates an upload URL to allow external clients to upload a file to the Media Manager.
Learn how to use the generated upload URL to [upload a file to the Media Manager](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/upload-api.md). > **Notes:** > - When you upload a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about [knowing when a file is ready](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/importing-files.md). > - Any interruption in the upload process stops the file upload. For files larger than 10MB, or when network connection is poor, call Generate File Resumable Upload URL instead. With the resumable upload URL, any interruption in the upload process pauses the file upload, and resumes the file upload process after the interruption. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: mimeType Method parameters: param name: mimeType | type: string | description: File mime type. | required: true param name: options | type: GenerateFileUploadUrlOptions none - name: fileName | type: string | description: Temporary file name used to identify the file type. For example, a file named "myFile.jpeg" identifies as an "image/jpeg" file type.
**Notes:** - name: parentFolderId | type: string | description: GUID of the file's parent folder.
This folder is the path root for the `filePath`.
Default: `media-root`. - name: private | type: boolean | description: Whether the file will be public or private. Learn more [about private files](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/private-files.md). - name: labels | type: array | description: Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by [Google Vision API](https://cloud.google.com/vision/docs/drag-and-drop) for images. - name: externalInfo | type: ExternalInfo | description: A place to map an external entity to an uploaded file in the Wix Media Manager. - name: origin | type: string | description: External information to specify in the File Ready or File Failed events. - name: externalIds | type: array | description: External GUIDs to specify in the File Ready or File Failed events. - name: filePath | type: string | description: Path to the folder where the file will be stored. For example, `/videos/2024/december`.
If `parentFolderId` is defined, the parent folder is used as the path root. Otherwise, the root is `media-root`. The folders in the path will be created if they don't already exist.
Return type: PROMISE - name: uploadUrl | type: string | description: The URL for uploading a file to the Media Manager. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: SITE_QUOTA_EXCEEDED | Description: Site quota has been exceeded. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FILE_SIZE_OVER_LIMIT | Description: File size exceeds the limit for this media type. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILE_FORMAT | Description: File format is recognized but not supported. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ZERO_FILE_SIZE | Description: File size is 0 bytes. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISMATCH_MIME_TYPE | Description: MIME type doesn't match the file extension. ``` ### Examples ### Use a file upload url in an external node.js application ```javascript /******************************** * External Node.js application * *******************************/ import axios from 'axios'; /* Sample fileName value: 'video1.mp4' * Sample contentType value: 'video/mp4' * Sample videoToUpload value: 'path/to/yourVideo.mp4' */ async function myUploadVideoFunction(generatedUploadUrl, videoToUpload, fileName, contentType) { const response = await axios.put(generatedUploadUrl, videoToUpload, { headers: { 'Content-Type': contentType }, params: { filename: fileName } }); return `${response[0].uploadUrl}`; } ``` ### Generate a file upload url (with elevated permissions) ```javascript import { files } from '@wix/media'; import { auth } from '@wix/essentials'; const elevatedGenerateFileUploadUrl = auth.elevate(files.generateFileUploadUrl); /* Sample mimeType value: 'image/jpeg' * Sample options value: * { * fileName: 'image1.jpeg', * parentFolderId: '103601562ec94214bee61f470b403dd5', * labels: ['nature', 'outdoors'] * } */ async function myGenerateFileUploadUrlFunction(mimeType, options) { try { const result = await elevatedGenerateFileUploadUrl(mimeType, options); const url = result.uploadUrl; return url; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "uploadUrl": "https://upload.wixmp.com/upload/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzYTk0N2E5Ni01ZmFiLTQ0NjAtODVkNS1hNTIxNWRjN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UzBwVWEydE5NREZOUkMwNFUzVTFVR1l4WWpWTWVsRXhNV0ZpYWt4M1pVWXdVMnRmV2xKZldHSTVja3Q1U0hadWRVSkxRMlJ1VWpCQlZGOTJjVnB5U2s5T1ZWbE1UM0JTVEU1bFExTlhjVzQzUzA1V2RuTjBVR2RyU3paMllXTnVjbTlRWDA5MGFTMUdOamRrU2tWelpWZFJhM0I2VW5WUGNIQkpTa1ZUUTJkMVpERkZRa2xOYlUxM1RWcGhWUzB4YUhoUk5HcFdWR2h2V1VJMU5FRnFhSGRpWlZSemRVbEVSRGxFT1dWWGVtaG5VVGhQZUV3MWVHdElORXN3UTFOWE5qSkRRazlQUlVrOUluMHNJbWhsWVdSbGNuTWlPbTUxYkd3c0luQmhjM04wYUhKdmRXZG9JanAwY25WbGZYMC5iRWJSTzdnYkQxaXR0TW9Hb29QUTBsbDZrbW5jSEdfc05pRjRXZzFZWTc0IiwiYWNsIjoicHVibGljIiwibWltZVR5cGUiOiJpbWFnZS9qcGVnIn0.pd9ZssMw0NOTIxmNm0gm3r5WP6ySCy4vBxlT8ufU_Vw" * } */ ``` ### Generate a file upload url ```javascript import { files } from '@wix/media'; /* Sample mimeType value: 'image/jpeg' * Sample options value: * { * fileName: 'image1.jpeg', * parentFolderId: '103601562ec94214bee61f470b403dd5', * labels: ['nature', 'outdoors'] * } */ async function myGenerateFileUploadUrlFunction(mimeType, options) { try { const result = await files.generateFileUploadUrl(mimeType, options); const url = result.uploadUrl; return url; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "uploadUrl": "https://upload.wixmp.com/upload/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzYTk0N2E5Ni01ZmFiLTQ0NjAtODVkNS1hNTIxNWRjNzRiMjEiLCJhdWQiOiJ1cm46c2VydmljZTp1cGxvYWQiLCJpc3MiOiJ1cm46c2VydmljZTp1cGxvYWQiLCJleHAiOjE2OTM5MTk3MjksImlhdCI6MTY5MzgzMzMxO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ZWbE1UM0JTVEU1bFExTlhjVzQzUzA1V2RuTjBVR2RyU3paMllXTnVjbTlRWDA5MGFTMUdOamRrU2tWelpWZFJhM0I2VW5WUGNIQkpTa1ZUUTJkMVpERkZRa2xOYlUxM1RWcGhWUzB4YUhoUk5HcFdWR2h2V1VJMU5FRnFhSGRpWlZSemRVbEVSRGxFT1dWWGVtaG5VVGhQZUV3MWVHdElORXN3UTFOWE5qSkRRazlQUlVrOUluMHNJbWhsWVdSbGNuTWlPbTUxYkd3c0luQmhjM04wYUhKdmRXZG9JanAwY25WbGZYMC5iRWJSTzdnYkQxaXR0TW9Hb29QUTBsbDZrbW5jSEdfc05pRjRXZzFZWTc0IiwiYWNsIjoicHVibGljIiwibWltZVR5cGUiOiJpbWFnZS9qcGVnIn0.pd9ZssMw0NOTIxmNm0gm3r5WP6ySCy4vBxlT8ufU_Vw" * } */ ``` ### generateFileUploadUrl (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { files } from '@wix/media'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { files }, // Include the auth strategy and host as relevant }); async function generateFileUploadUrl(mimeType,options) { const response = await myWixClient.files.generateFileUploadUrl(mimeType,options); }; ``` ---