Search...
getFolder( )
Gets information from the specified folder in the Media Manager.
Description
The getFolder()
function returns a Promise that resolves to information about the specified folder.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function getFolder(folderId: string): Promise<Folder>
getFolder Parameters
NAME
TYPE
DESCRIPTION
folderId
string
Folder ID.
Returns
Information about the folder.
Return Type:
Promise<
Folder
>NAME
TYPE
DESCRIPTION
_createdDate
Date
Date the folder was created.
_id
string
Folder ID. Generated when a folder is created in the Media Manager.
_updatedDate
Date
Date the folder was updated.
displayName
string
Folder name as it appears in the Media Manager.
parentFolderId
string
ID of the folder's parent folder.
Default: media-root
folder.
state
string
State of the folder.
Supported values: "OK"
, "DELETED"
.
Was this helpful?
Get a folder (dashboard page code)
Copy Code
1import { folders } from 'wix-media.v2';23/* Sample folderId value: '30ed8f8a8f1e4a99b82c516cb212192f' */45async function myGetFolderFunction(folderId) {6 try {7 const folder = await folders.getFolder(folderId);89 console.log('Successfully retrieved folder:', folder);10 return folder;11 } catch (error) {12 console.error(error);13 // Handle the error14 }15}1617/* Promise resolves to:18 * {19 * "_createdDate": "2023-08-22T08:31:06.000Z",20 * "_id": "30ed8f8a8f1e4a99b82c516cb212192f",21 * "_updatedDate": "2023-08-22T08:31:06.000Z",22 * "displayName": "test2",23 * "parentFolderId": "302fc049d70c41dea33fa4a27ab481ba",24 * "state": "OK"25 * }26 */
Get a folder (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { folders } from 'wix-media.v2';3import { elevate } from 'wix-auth';45/* Sample folderId value: '30ed8f8a8f1e4a99b82c516cb212192f' */67export const myGetFolderFunction = webMethod(Permissions.Anyone, async (folderId) => {8 try {9 const elevatedGetFolder = elevate(folders.getFolder);10 const folder = await elevatedGetFolder(folderId);1112 console.log('Successfully retrieved folder:', folder);13 return folder;14 } catch (error) {15 console.error(error);16 // Handle the error17 }18});1920/* Promise resolves to:21 * {22 * "_createdDate": "2023-08-22T08:31:06.000Z",23 * "_id": "30ed8f8a8f1e4a99b82c516cb212192f",24 * "_updatedDate": "2023-08-22T08:31:06.000Z",25 * "displayName": "test2",26 * "parentFolderId": "302fc049d70c41dea33fa4a27ab481ba",27 * "state": "OK"28 * }29 */30