Introduction
Â
APIs in Developer Preview are subject to change and are not intended for use in production.
Send us your suggestions for improving this API. Your feedback is valuable to us.
Â
The Folders API allows you to manage the folders in your Media Manager.
With the Folders API, you can:
Setup
To use the Folders API, install the @wix/media
package using npm or Yarn:
1npm install @wix/media
or
1yarn add @wix/media
Then import { folders }
from @wix/media
:
1import { folders } from '@wix/media'
Temporarily deletes the specified folders from the Media Manager.
The bulkDeleteFolders()
function returns a Promise that resolves when the folders are deleted.
The deleted folders are moved to the Media Manager's TRASH_ROOT
folder (trash bin) unless permanently deleted. To permanently delete folders, pass the permanent
parameter with the value true
. Permanently deleting folders isn't reversible, so make sure that the files in these folders aren't being used in a site or in any other way as the files will no longer be accessible.
Notes:
- When a folder is deleted, the files in that folder are deleted.
- The specified folders can be from different parent folders.
- Moving multiple folders at once is an asynchronous action, and may take time for the changes to appear in the Media Manager.
- Attempting to delete folders that are already in the trash bin doesn't result in an error.
- If your site contains files from a non-permanently deleted media folder, the files still appear on your site as the deleted folder is still in the Media Manager (in the trash bin).
- You can use the
bulkRestoreFoldersFromTrashBin()
function to restore folders from the Media Manager's trash bin.
Permission Scopes
For app development, you must have one of the following permission scopes:function bulkDeleteFolders(folderIds: Array<string>, options: BulkDeleteFoldersOptions): Promise<void>
IDs of the folders to move to the Media Manager's trash bin.
Options to use when deleting folders.
Restores the specified folders from the Media Manager's trash bin, and moves them to their original locations in the Media Manager.
The bulkRestoreFoldersFromTrashBin()
function returns a Promise that resolves when the folders have been restored.
Permission Scopes
For app development, you must have one of the following permission scopes:function bulkRestoreFoldersFromTrashBin(folderIds: Array<string>): Promise<void>
IDs of the folders to restore from the Media Manager's trash bin.
Creates a new folder in the Media Manager.
The createFolder()
function returns a Promise that resolves to the created folder.
Use the parentFolderId
parameter to specify in which existing folder you want the new folder to be created.
If no folder is specified, the new folder is created in the media-root
folder.
Permission Scopes
For app development, you must have one of the following permission scopes:function createFolder(displayName: string, options: CreateFolderOptions): Promise<CreateFolderResponse>
Folder name that appears in the Media Manager.
Options for specifying where to create a folder.
Generates a URL for downloading a compressed file containing a specific folder in the Media Manager.
The generateFolderDownloadUrl()
function returns a Promise that resolves to a download URL.
The compressed file can contain sub-folders, and up to 1000 files.
Permission Scopes
For app development, you must have one of the following permission scopes:function generateFolderDownloadUrl(folderId: string): Promise<GenerateFolderDownloadUrlResponse>
Folder ID.
Gets information from the specified folder in the Media Manager.
The getFolder()
function returns a Promise that resolves to information about the specified folder.
Permission Scopes
For app development, you must have one of the following permission scopes:function getFolder(folderId: string): Promise<Folder>
Folder ID.
Retrieves a list of deleted folders from the trash bin.
The listDeletedFolders()
function returns a Promise that resolves to information about the specified deleted folders and cursor information.
To retrieve a list of non-deleted folders, use the listFolders()
function.
Permission Scopes
For app development, you must have one of the following permission scopes:function listDeletedFolders(options: ListDeletedFoldersOptions): Promise<ListDeletedFoldersResponse>
Options to use when listing deleted folders from the trash bin.
Retrieves a list of folders in the Media Manager.
The listFolders()
function returns a Promise that resolves to information about the specified folders and cursor information.
To retrieve a list of folders within a specific folder in the Media Manager, pass the specific folder's ID in the parentFolderId
parameter. If no folder is specified, the function retrieves only the list of folders within the root folder of the Media Manager.
To retrieve a list of (non-permanently) deleted folders, use the listDeletedFolders()
function.
Permission Scopes
For app development, you must have one of the following permission scopes:function listFolders(options: ListFoldersOptions): Promise<ListFoldersResponse>
Options to use when listing folders from the Media Manager.
Searches the Media Manager and returns a list of folders that match the terms specified in the parameters.
The searchFolders()
function returns a Promise that resolves to information about the specified folders and cursor information.
If no parameters are specified, the function returns all folders in the MEDIA_ROOT
folder.
Permission Scopes
For app development, you must have one of the following permission scopes:function searchFolders(options: SearchFoldersOptions): Promise<SearchFoldersResponse>
Options specifying which folders to search.
Updates a folder.
The updateFolder()
function returns a Promise that resolves to information about the updated folder.
You can use the parentFolderId
parameter to move a folder from its current parent folder to a different parent folder.
Permission Scopes
For app development, you must have one of the following permission scopes:function updateFolder(_id: string, folder: UpdateFolder): Promise<Folder>
Folder ID. Generated when a folder is created in the Media Manager.
Folder to update.