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)
.
function listFolders(
filters: FolderFilterOptions,
sorting: SortingOptions,
paging: PagingOptions,
): Promise<Array<FolderInfo>>;
Folder filter options.
Sorting options.
Paging options.
import { Permissions, webMethod } from "wix-web-module";
import { mediaManager } from "wix-media-backend";
const filters = {
parentFolderId: "8a3be85ea03e4b8b82f2f9c989557c3d",
};
export const myListFoldersFunction = webMethod(Permissions.Anyone, () => {
return mediaManager
.listFolders(filters, null, null)
.then((myFolders) => {
const folderName = myFolders[0].folderName;
const updatedDate = myFolders[1]._updatedDate;
return myFolders;
})
.catch((error) => {
console.error(error);
});
});
/* Returns a promise that resolves to:
* [{
* "folderId": "1bf317e889264736b5acb367415fad8e",
* "folderName": "greatfolder1",
* "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d",
* "_createdDate": "Sun December 4 2020 14:56:15 GMT+0300",
* "_updatedDate": "Wed May 12 2021 14:56:15 GMT+0300"
* },
* {
* "folderId": "2fj678p889264736b5acb367415fad5g",
* "folderName": "greatfolder2",
* "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d",
* "_createdDate": "Sun December 4 2020 14:56:15 GMT+0300",
* "_updatedDate": "Wed May 12 2021 14:56:15 GMT+0300"
* }]
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.