Introduction

 

Developer Preview
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:

Was this helpful?
Yes
No

Setup

To use the Folders API, install the @wix/media package using npm or Yarn:

Copy
1
npm install @wix/media

or

Copy
1
yarn add @wix/media

Then import { folders } from @wix/media:

Copy
1
import { folders } from '@wix/media'
Was this helpful?
Yes
No

bulkDeleteFolders( )

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:
Manage Bookings Services and Settings
Manage Media Manager
Learn more about permission scopes.
Copy
function bulkDeleteFolders(folderIds: Array<string>, options: BulkDeleteFoldersOptions): Promise<void>
Method Parameters
folderIdsArray<string>Required

IDs of the folders to move to the Media Manager's trash bin.


optionsBulkDeleteFoldersOptions

Options to use when deleting folders.

Was this helpful?
Yes
No

bulkRestoreFoldersFromTrashBin( )

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:
Manage Bookings Services and Settings
Manage Media Manager
Learn more about permission scopes.
Copy
function bulkRestoreFoldersFromTrashBin(folderIds: Array<string>): Promise<void>
Method Parameters
folderIdsArray<string>Required

IDs of the folders to restore from the Media Manager's trash bin.

Was this helpful?
Yes
No

createFolder( )

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:
Manage Bookings Services and Settings
Manage Media Manager
Learn more about permission scopes.
Copy
function createFolder(displayName: string, options: CreateFolderOptions): Promise<CreateFolderResponse>
Method Parameters
displayNamestringRequired

Folder name that appears in the Media Manager.


optionsCreateFolderOptions

Options for specifying where to create a folder.

Returns
Return Type:Promise<CreateFolderResponse>
Was this helpful?
Yes
No

generateFolderDownloadUrl( )

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:
Manage Bookings Services and Settings
Manage Media Manager
Learn more about permission scopes.
Copy
function generateFolderDownloadUrl(folderId: string): Promise<GenerateFolderDownloadUrlResponse>
Method Parameters
folderIdstringRequired

Folder ID.

Returns
Return Type:Promise<GenerateFolderDownloadUrlResponse>
Was this helpful?
Yes
No

getFolder( )

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:
Manage Bookings Services and Settings
Read Media Manager
Manage Media Manager
Learn more about permission scopes.
Copy
function getFolder(folderId: string): Promise<Folder>
Method Parameters
folderIdstringRequired

Folder ID.

Returns
Return Type:Promise<Folder>
Was this helpful?
Yes
No

listDeletedFolders( )

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:
Manage Bookings Services and Settings
Read Media Manager
Manage Media Manager
Learn more about permission scopes.
Copy
function listDeletedFolders(options: ListDeletedFoldersOptions): Promise<ListDeletedFoldersResponse>
Method Parameters
optionsListDeletedFoldersOptions

Options to use when listing deleted folders from the trash bin.

Returns
Return Type:Promise<ListDeletedFoldersResponse>
Was this helpful?
Yes
No

listFolders( )

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:
Manage Bookings Services and Settings
Read Media Manager
Manage Media Manager
Learn more about permission scopes.
Copy
function listFolders(options: ListFoldersOptions): Promise<ListFoldersResponse>
Method Parameters
optionsListFoldersOptions

Options to use when listing folders from the Media Manager.

Returns
Return Type:Promise<ListFoldersResponse>
Was this helpful?
Yes
No

searchFolders( )

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:
Manage Bookings Services and Settings
Read Media Manager
Manage Media Manager
Learn more about permission scopes.
Copy
function searchFolders(options: SearchFoldersOptions): Promise<SearchFoldersResponse>
Method Parameters
optionsSearchFoldersOptions

Options specifying which folders to search.

Returns
Return Type:Promise<SearchFoldersResponse>
Was this helpful?
Yes
No

updateFolder( )

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:
Manage Bookings Services and Settings
Manage Media Manager
Learn more about permission scopes.
Copy
function updateFolder(_id: string, folder: UpdateFolder): Promise<Folder>
Method Parameters
_idstringRequired

Folder ID. Generated when a folder is created in the Media Manager.


folderUpdateFolderRequired

Folder to update.

Returns
Return Type:Promise<Folder>
Was this helpful?
Yes
No