getFileUrl( )


Deprecated. This function will continue to work, but a newer version is available. Use the getDownloadUrl function instead.

Note: The new getDownloadUrl function contains additional parameters.

Gets a temporary download URL with a token from the Media Manager for a specified file.

The getFileUrl() function returns a Promise that resolves to a download URL for the specified file.

Pass a Media Manager file URL in the fileUrl parameter, as returned in the fileUrl property from the getFileInfo(), importFile(), and upload() functions.

Method Declaration
Copy
Method Parameters
fileUrlstringRequired

The file's Wix media URL in the following format: 'wix:image://v1//#originWidth=&originHeight=[&watermark=]'.

Note: This replaces the old fileName parameter. fileName will continue to work, but we recommend that you use the updated fileUrl parameter instead.

Returns
Return Type:Promise<string>
Get a file's URL

This example uses a deprecated function.

JavaScript
Did this help?

getFolderInfo( )


Gets a folder's information from the Media Manager by folderId.

The getFolderInfo() function returns a Promise that resolves to information about the specified folder.

The folderId property is the internal name (unique identifier) which is generated when a folder is created by the Media Manager.

Method Declaration
Copy
Method Parameters
folderIdstringRequired

Internal name (unique identifier) which is generated when a folder is created by the Media Manager.

Returns
Return Type:Promise<FolderInfo>
Get a folder's information
JavaScript
Did this help?

getUploadUrl( )


Gets an upload URL for uploading a file to the media manager.

The getUploadUrl() function returns a Promise that resolves to an object containing an upload URL.

Use the getUploadUrl() function to allow an external client to upload a single file to your site's Media Manager.

Note: The upload URL is valid for a single file upload and expires after 1 day. The getUploadUrl() function must be called for each file that you want to upload.

The external client uploads a file by sending a POST or PUT request to the URL returned by getUploadUrl() using multipart/form-data encoding and sending the following data:

Copy
  • upload_url: The returned upload URL.

  • file: An object containing:

    • value: The file content as a multi-part value.

    • options: An object containing:

      • filename: The name of the file as it will appear in the Media Manager.
      • contentType: The content type of the file.

The POST or PUT request returns the following:

Copy

To get a Wix image URL that can be stored in a collection or displayed in an image element or gallery from the above object, use the following expression:

Copy
Method Declaration
Copy
Method Parameters
pathstringRequired

The path within the Media Manager where the file will be uploaded. If the path doesn't yet exist, the missing folders will be created.


optionsUploadOptionsRequired

Options to use when uploading the file.

Returns
Return Type:Promise<UploadUrl>

This example demonstrates how to generate a URL that an external application can use to upload a file to your site's Media Manager.

JavaScript
Did this help?

getVideoPlaybackUrl( )


Gets a video file's playback URL from the Media Manager.

The getVideoPlaybackUrl() function returns a Promise that resolves to the specified video file's playback URL.

Method Declaration
Copy
Method Parameters
fileUrlstringRequired

The file's Wix media URL in the following format: 'wix:image://v1//#originWidth=&originHeight=[&watermark=]'.

Note: This replaces the old fileName parameter. fileName will continue to work, but we recommend that you use the updated fileUrl parameter instead.


formatstringRequired

The format of the URL to get. Either "hls" or "dash".

Returns
Return Type:Promise<string>
Get a URL to be used for video playback
JavaScript
Did this help?

importFile( )


Imports a file to the Media Manager from a URL.

The importFile() function returns a Promise that resolves to information about the newly imported file.

Video and audio files that have been imported aren't immediately available to be used even after the Promise is resolved. Before they can be used, they must first undergo transcoding. The onFileUploaded() event is triggered when an imported file has been uploaded and before the transcoding is finished. As a result, some properties such as the fileUrl may not initially appear in the returns.

Note: Receiving a response does not indicate that the import is complete. To run code when the import finishes, implement the relevant event. See Importing and Uploading Files to learn more.

Method Declaration
Copy
Method Parameters
pathstringRequired

The path within the Media Manager where the file will be uploaded. If the path doesn't yet exist, the missing folders will be created, for example: /media/files.

If metadataOptions.isVisitorUpload is true (default), the visitor-uploads folder is the root of the file path, in this case, visitor-uploads/media/files/.


urlstringRequired

The file's external URL, where it was imported from.


optionsUploadOptionsRequired

Options to use when uploading a file

Returns
Return Type:Promise<FileInfo>
Import a file
JavaScript
Did this help?

listFiles( )


Gets a list of files from the Media Manager by parentFolderId (or root).

The listFiles() function returns a Promise that resolves to information about the files in the folder.

To get a list of files within a specific folder in the Media Manager, pass the folder's ID in the parentFolderId parameter. If no folder is specified, the listFiles() function returns the list of files in the root folder of the Media Manager.

Notes:

  • This function's parameters are positional, and must be specified in the sequence shown in the syntax below. When specifying a parameter, use null as a placeholder for any unspecified parameters. For example, to specify parentFolderId only, call listFiles(filters, null, null). For example, to specify sorting only, call listFiles(null, sorting, null).

  • The listFiles() function only gets a list of files with supported media types, and that are explicitly listed in the Media Manager. Files with unsupported media types such as 'model', and files that aren't explicitly listed in the Media Manager such as default files in a gallery component, aren't listed when calling the listFiles() function. The supported media types are listed in the description for the mediaType return in the getFileInfo() function.

Method Declaration
Copy
Method Parameters
filtersFileFilterOptions

File filter options.


sortingSortingOptions

Sorting options.


pagingPagingOptions

Paging options.

Returns
Return Type:Promise<Array<File>>
JavaScript
Did this help?

listFolders( )


Gets a list of folders from the Media Manager by parentFolderId (or root).

The listFolders() function returns a Promise that resolves to information about the folders in the folder.

To get a list of folders within a specific folder in the Media Manager, pass the folder's ID in the parentFolderId parameter. If no folder is specified, the listFolders() function returns the list of folders in the root folder of the Media Manager.

Note: This function's parameters are positional, and must be specified in the sequence shown in the syntax below. When specifying a parameter, use null as a placeholder for any unspecified parameters. For example, to specify parentFolderId only, call listFolders(filters, null, null). For example, to specify sorting only, call listFolders(null, sorting, null).

Method Declaration
Copy
Method Parameters
filtersFolderFilterOptions

Folder filter options.


sortingSortingOptions

Sorting options.


pagingPagingOptions

Paging options.

Returns
Return Type:Promise<Array<FolderInfo>>
JavaScript
Did this help?

moveFilesToTrash( )


Moves single or multiple files to the Media Manager's trash.

The moveFilesToTrash() function returns a Promise that resolves when the file(s) are moved to the Media Manager's trash.

Moving many files to trash at once is an asynchronous action. It may take some time for the results to be seen in the Media Manager.

Use the Media Manager to restore or permanently delete the trashed files.

Attempting to move already-trashed files to trash again doesn't result in an error.

Method Declaration
Copy
Method Parameters
fileUrlsArray<string>Required

URLs of the files to move to trash.

JavaScript
Did this help?

moveFoldersToTrash( )


Moves single or multiple folders, including their files and sub-folders, to the Media Manager's trash.

The moveFoldersToTrash() function returns a Promise that resolves when the folder(s) are moved to the Media Manager's trash.

Moving many folders to trash at once is an asynchronous action. It may take some time for the results to be seen in the Media Manager.

Use the Media Manager to restore or permanently delete trashed folders.

Attempting to move already-trashed folders to trash again doesn't result in an error.

Method Declaration
Copy
function moveFoldersToTrash(folderIds: Array<string>): Promise<void>;
Method Parameters
folderIdsArray<string>Required

IDs of the folders to move to trash.

Move a single folder to trash
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { mediaManager } from "wix-media-backend"; /* Sample folderIds array: * [ * 'de4e7c3258f444e9a506a8572d951ddf', * 'a2597566072c463492f9963c377f3f74' * ] */ export const myMoveFoldersToTrashFunction = webMethod( Permissions.Anyone, (folderIds) => { return mediaManager .moveFoldersToTrash(folderIds) .then(() => { console.log("Success! Folders have been trashed."); }) .catch((error) => { console.error(error); }); }, ); /** * Returns a promise that resolves to <void> **/
Did this help?