Search.../

bulkRestoreFoldersFromTrashBin( )

Developer Preview

Restores the specified folders from the Media Manager's trash bin, and moves them to their original locations in the Media Manager.

Description

The bulkRestoreFoldersFromTrashBin() function returns a Promise that resolves when the folders have been restored.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function bulkRestoreFoldersFromTrashBin(folderIds: Array<string>): Promise<void>

bulkRestoreFoldersFromTrashBin Parameters

NAME
TYPE
DESCRIPTION
folderIds
Array<
string
>

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

Returns

Return Type:

Promise<
void
>

Was this helpful?

Bulk restore (non-permanently deleted) folders

Copy Code
1import { folders } from 'wix-media.v2';
2import { elevate } from 'wix-auth';
3
4/* Sample folderIds value:
5 * [
6 * 'd4051a6890724365a78678a6208ac37e',
7 * '302fc049d70c41dea33fa4a27ab481ba'
8 * ]
9 */
10
11async function myBulkRestoreFoldersFromTrashBinFunc(folderIds) {
12 try {
13 const elevatedBulkRestoreFoldersFromTrashBin = elevate(folders.bulkRestoreFoldersFromTrashBin);
14 const restoredFolders = await elevatedBulkRestoreFoldersFromTrashBin(folderIds);
15
16 console.log('Restored deleted folders:', restoredFolders);
17 return restoredFolders;
18 } catch (error) {
19 console.error(error);
20 // Handle the error
21 }
22}
23
24 /* Promise resolves to void */
Bulk restore all folders from the trash bin

Copy Code
1/**************************************
2 * Backend code - restore-folders.jsw *
3 *************************************/
4
5import { folders } from 'wix-media.v2';
6import { elevate } from 'wix-auth';
7
8async function restoreAllFolders() {
9 try {
10 const elevatedListDeletedFolders = elevate(folders.listDeletedFolders);
11 const deletedFolders = await elevatedListDeletedFolders();
12
13 const deletedFolderIds = deletedFolders.map((folder) => {
14 return folder._id;
15 });
16
17 const elevatedBulkRestoreFoldersFromTrashBin = elevate(folders.bulkRestoreFoldersFromTrashBin);
18 const restoredFolders = await elevatedBulkRestoreFoldersFromTrashBin(deletedFolderIds);
19
20 return restoredFolders;
21 } catch (error) {
22 console.error(error);
23 }
24}
25
26
27/*************
28 * Page code *
29 ************/
30
31import { restoreAllFolders } from 'backend/restore-folders';
32
33$w.onReady(async () => {
34 $w('#restoreAll').onClick(async () => {
35 const restoredFolders = await restoreAllFolders();
36
37 console.log('Restored all folders:', restoredFolders);
38 $w('#bulkRestoreSuccessMsg').show();
39 });
40});
41