listFolders( )
Gets a list of folders from the Media Manager by parentFolderId
(or root).
Description
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 specifyparentFolderId
only, calllistFolders(filters, null, null)
. For example, to specifysorting
only, calllistFolders(null, sorting, null)
.
Syntax
function listFolders([filters: FolderFilterOptions], [sorting: SortingOptions], [paging: PagingOptions]): FolderInfo
listFolders Parameters
NAME
TYPE
DESCRIPTION
Folder filter options.
Sorting options.
Paging options.
Returns
Fulfilled - Information about the folders.
Return Type:
NAME
TYPE
DESCRIPTION
ID of the folder. Internal name (unique identifier) which is generated when a folder is created by the Media Manager. Use this ID when calling the listFiles()
, and listFolders()
functions.
Name of the folder.
ID of the folder's parent folder. Use this ID when calling the listFiles()
, and listFolders()
functions.
Date the folder was created.
Date the folder was updated.
Was this helpful?
1import { mediaManager } from 'wix-media-backend';23const filters = {4 parentFolderId: "8a3be85ea03e4b8b82f2f9c989557c3d"5};67export function myListFoldersFunction() {8 return mediaManager.listFolders(filters, null, null)9 .then((myFolders) => {10 const folderName = myFolders[0].folderName;11 const updatedDate = myFolders[1]._updatedDate;12 return myFolders;13 })14 .catch((error) => {15 console.error(error);16 });17}1819/* Returns a promise that resolves to:20 * [{21 * "folderId": "1bf317e889264736b5acb367415fad8e",22 * "folderName": "greatfolder1",23 * "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d",24 * "_createdDate": "Sun December 4 2020 14:56:15 GMT+0300",25 * "_updatedDate": "Wed May 12 2021 14:56:15 GMT+0300"26 * },27 * {28 * "folderId": "2fj678p889264736b5acb367415fad5g",29 * "folderName": "greatfolder2",30 * "parentFolderId": "8a3be85ea03e4b8b82f2f9c989557c3d",31 * "_createdDate": "Sun December 4 2020 14:56:15 GMT+0300",32 * "_updatedDate": "Wed May 12 2021 14:56:15 GMT+0300"33 * }]34 */
1import { mediaManager } from 'wix-media-backend';23export function myListFoldersFunction() {4 return mediaManager.listFolders()5 .then((myFolders) => {6 const folderName = myFolders[0].folderName;7 const updatedDate = myFolders[1]._updatedDate;8 return myFolders;9 })10 .catch((error) => {11 console.error(error);12 });13}1415/* Returns a promise that resolves to:16 * [{17 * "folderId": "4nm317e889264736b5acb367415fad6b",18 * "folderName": "folder1",19 * "parentFolderId": "media-root",20 * "_createdDate": "Mon August 5 2019 14:56:15 GMT+0300",21 * "_updatedDate": "Tues May 12 2021 07:28:12 GMT+0300"22 * },23 * {24 * "folderId": "2t214e889264736b5acb367415fadgc",25 * "folderName": "folder2",26 * "parentFolderId": "media-root",27 * "_createdDate": "Sun December 16 2018 12:22:22 GMT+0300",28 * "_updatedDate": "Wed June 11 2020 09:34:33 GMT+0300"29 * }]30 */
In this example we list folders in a specified folder, and sort them in ascending alphabetical order according to the folder name. We skip the first folder in the list and limit the result to the next 2 folders in the list.
1import { mediaManager } from 'wix-media-backend';23const filters = {4 parentFolderId: "8292670cf5434db787bdd9715b46b989"5};67const sorting = {8 order: "asc",9 field: "folderName"10};1112const paging = {13 limit: 2,14 skip: 115};1617export function myListFoldersFunction() {18 return mediaManager.listFolders(filters, sorting, paging)19 .then((myFolders) => {20 const folderName = myFolders[0].folderName;21 const updatedDate = myFolders[1]._updatedDate;22 return myFolders;23 })24 .catch((error) => {25 console.error(error);26 });27}2829/* Returns a promise that resolves to:30 * [{31 * "folderId": "1bf317e889264736b5acb367415fad8e",32 * "folderName": "pictures",33 * "parentFolderId": "8292670cf5434db787bdd9715b46b989",34 * "_createdDate": "Sat July 4 2017 10:28:12 GMT+0300",35 * "_updatedDate": "Wed September 17 2020 09:06:15 GMT+0300"36 * },37 * {38 * "folderId": "2t214e889264736b5acb367415fadgc",39 * "folderName": "videos",40 * "parentFolderId": "8292670cf5434db787bdd9715b46b989",41 * "_createdDate": "Sun December 16 2018 12:22:22 GMT+0300",42 * "_updatedDate": "Wed June 11 2020 09:34:33 GMT+0300"43 * }]44 */4546