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';
2
3/* Sample folderId value: '30ed8f8a8f1e4a99b82c516cb212192f' */
4
5async function myGetFolderFunction(folderId) {
6 try {
7 const folder = await folders.getFolder(folderId);
8
9 console.log('Successfully retrieved folder:', folder);
10 return folder;
11 } catch (error) {
12 console.error(error);
13 // Handle the error
14 }
15}
16
17/* 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';
4
5/* Sample folderId value: '30ed8f8a8f1e4a99b82c516cb212192f' */
6
7export const myGetFolderFunction = webMethod(Permissions.Anyone, async (folderId) => {
8 try {
9 const elevatedGetFolder = elevate(folders.getFolder);
10 const folder = await elevatedGetFolder(folderId);
11
12 console.log('Successfully retrieved folder:', folder);
13 return folder;
14 } catch (error) {
15 console.error(error);
16 // Handle the error
17 }
18});
19
20/* 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