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.
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.
This example uses a deprecated function.
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.
Internal name (unique identifier) which is generated when a folder is created by the Media Manager.
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:
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:
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:
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.
Options to use when uploading the file.
This example demonstrates how to generate a URL that an external application can use to upload a file to your site's Media Manager.
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.
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.
The format of the URL to get. Either "hls"
or "dash"
.
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.
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/
.
The file's external URL, where it was imported from.
Options to use when uploading a file
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.
File filter options.
Sorting options.
Paging options.
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)
.
Folder filter options.
Sorting options.
Paging options.
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.
URLs of the files to move to trash.
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.
function moveFoldersToTrash(folderIds: Array<string>): Promise<void>;
IDs of the folders to move to trash.
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>
**/