> 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: channels # Namespace: CommunicationChannelsMedia # Method link: https://dev.wix.com/docs/api-reference/crm/communication/channels/communication-channels-media/generate-file-upload-url.md ## Permission Scopes: Manage Inbox Messages: SCOPE.DC-INBOX.MANAGE-MSGS ## Introduction Generates a secure upload URL for storing a file in the Media Manager. To upload the file to the Media Manager after calling this method, call the Media Manager's [Upload API](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/upload-api.md) with the `uploadUrl` response. Call this method to upload files to the Media Manager from a local device, such as a computer or phone. >**Note:** Due to limits on the size and duration of files that you can upload, we recommend importing files to the Media Manager by calling the [Import File](https://dev.wix.com/docs/api-reference/crm/communication/channels/communication-channels-media/import-file.md) method. See [Wix Media: Supported Media File Types and File Sizes](https://support.wix.com/en/article/wix-media-supported-media-file-types-and-file-sizes) for more details. --- ## REST API ### Schema ``` Method: generateFileUploadUrl Description: Generates a secure upload URL for storing a file in the Media Manager. To upload the file to the Media Manager after calling this method, call the Media Manager's [Upload API](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/upload-api.md) with the `uploadUrl` response. Call this method to upload files to the Media Manager from a local device, such as a computer or phone. >**Note:** Due to limits on the size and duration of files that you can upload, we recommend importing files to the Media Manager by calling the [Import File](https://dev.wix.com/docs/api-reference/crm/communication/channels/communication-channels-media/import-file.md) method. See [Wix Media: Supported Media File Types and File Sizes](https://support.wix.com/en/article/wix-media-supported-media-file-types-and-file-sizes) for more details. URL: https://www.wixapis.com/v1/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: fileName | type: fileName | description: File name used to identify the file type. For example, `myFile.jpeg` identifies as an `image/jpeg` file type. param name: mimeType | type: mimeType | description: File mime type. | required: true Return type: GenerateFileUploadUrlResponse - name: uploadUrl | type: string | description: Temporary URL for uploading a file to the Media Manager. The URL is valid for 10 hours. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FILE_SIZE_OVER_LIMIT | Description: File size exceeds the allowed limit for this media type. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILE_FORMAT | Description: File format not supported. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ZERO_FILE_SIZE | Description: File can't be empty. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MIME_TYPE_MISMATCH | Description: MIME type doesn't match the file extension. ``` ### Examples ### Generate a file upload URL ```curl curl -X POST \ 'https://www.wixapis.com/communication-channels-media/v1/upload-url' \ -H 'Authorization: ' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.channels.CommunicationChannelsMedia.generateFileUploadUrl(options) Description: Generates a secure upload URL for storing a file in the Media Manager. To upload the file to the Media Manager after calling this method, call the Media Manager's [Upload API](https://dev.wix.com/docs/api-reference/assets/media/media-manager/files/upload-api.md) with the `uploadUrl` response. Call this method to upload files to the Media Manager from a local device, such as a computer or phone. >**Note:** Due to limits on the size and duration of files that you can upload, we recommend importing files to the Media Manager by calling the [Import File](https://dev.wix.com/docs/api-reference/crm/communication/channels/communication-channels-media/import-file.md) method. See [Wix Media: Supported Media File Types and File Sizes](https://support.wix.com/en/article/wix-media-supported-media-file-types-and-file-sizes) for more details. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: options.mimeType, options Method parameters: param name: options | type: GenerateFileUploadUrlOptions none | required: true - name: fileName | type: string | description: File name used to identify the file type. For example, `myFile.jpeg` identifies as an `image/jpeg` file type. - name: mimeType | type: string | description: File mime type. | required: true Return type: PROMISE - name: uploadUrl | type: string | description: Temporary URL for uploading a file to the Media Manager. The URL is valid for 10 hours. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FILE_SIZE_OVER_LIMIT | Description: File size exceeds the allowed limit for this media type. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILE_FORMAT | Description: File format not supported. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ZERO_FILE_SIZE | Description: File can't be empty. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MIME_TYPE_MISMATCH | Description: MIME type doesn't match the file extension. ``` ### Examples ### generateFileUploadUrl ```javascript import { communicationChannelsMedia } from '@wix/comm-channels-media'; async function generateFileUploadUrl(options) { const response = await communicationChannelsMedia.generateFileUploadUrl(options); }; ``` ### generateFileUploadUrl (with elevated permissions) ```javascript import { communicationChannelsMedia } from '@wix/comm-channels-media'; import { auth } from '@wix/essentials'; async function myGenerateFileUploadUrlMethod(options) { const elevatedGenerateFileUploadUrl = auth.elevate(communicationChannelsMedia.generateFileUploadUrl); const response = await elevatedGenerateFileUploadUrl(options); } ``` ### 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 { communicationChannelsMedia } from '@wix/comm-channels-media'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { communicationChannelsMedia }, // Include the auth strategy and host as relevant }); async function generateFileUploadUrl(options) { const response = await myWixClient.communicationChannelsMedia.generateFileUploadUrl(options); }; ``` ---