> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # BulkRestoreFoldersFromTrashBin # Package: mediaManager # Namespace: FoldersService # Method link: https://dev.wix.com/docs/api-reference/assets/media/media-manager/folders/bulk-restore-folders-from-trash-bin.md ## Permission Scopes: Manage Media Manager: SCOPE.DC-MEDIA.MANAGE-MEDIAMANAGER ## Introduction Restores the specified folders from the Media Manager's trash bin, and moves them to their original locations in the Media Manager. --- ## REST API ### Schema ``` Method: bulkRestoreFoldersFromTrashBin Description: Restores the specified folders from the Media Manager's trash bin, and moves them to their original locations in the Media Manager. URL: https://www.wixapis.com/site-media/v1/bulk/trash-bin/folders/restore Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: folderIds Method parameters: param name: folderIds | type: array | description: IDs of the folders to restore from the Media Manager's trash bin. | required: true Return type: BulkRestoreFoldersFromTrashBinResponse EMPTY-OBJECT {} ``` ### Examples ### Bulk restore deleted folders and their content ```curl curl -X POST \ 'https://www.wixapis.com/site-media/v1/bulk/trash-bin/folders/restore' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ --data-binary '{ "folderIds": ["25284aa06584441ea94338fdcfbaba12", "9v38fdcfbaba12eeb55bcf5c41eca01c0"] }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.mediaManager.FoldersService.bulkRestoreFoldersFromTrashBin(folderIds) Description: Restores the specified folders from the Media Manager's trash bin, and moves them to their original locations in the Media Manager. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: folderIds Method parameters: param name: folderIds | type: array | description: IDs of the folders to restore from the Media Manager's trash bin. | required: true Return type: PROMISE EMPTY-OBJECT {} ``` ### Examples ### Bulk restore all folders from the trash bin (with $w) ```javascript /******************************************** * Backend code - restore-folders.web.js/ts * *******************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { folders } from '@wix/media'; import { auth } from '@wix/essentials'; export const restoreAllFolders = webMethod(Permissions.Anyone, async () => { try { const elevatedListDeletedFolders = auth.elevate(folders.listDeletedFolders); const deletedFolders = await elevatedListDeletedFolders(); const deletedFolderIds = deletedFolders.folders.map((folder) => { return folder._id; }); const elevatedBulkRestoreFoldersFromTrashBin = auth.elevate(folders.bulkRestoreFoldersFromTrashBin); const restoredFolders = await elevatedBulkRestoreFoldersFromTrashBin(deletedFolderIds); return restoredFolders; } catch (error) { console.error(error); } }); /************* * Page code * ************/ import { restoreAllFolders } from 'backend/restore-folders.web'; $w.onReady(async () => { $w('#restoreAll').onClick(async () => { const restoredFolders = await restoreAllFolders(); console.log('Restored all folders:', restoredFolders); $w('#bulkRestoreSuccessMsg').show(); }); }); ``` ### Bulk restore (non-permanently deleted) folders (with elevated permissions) ```javascript import { folders } from '@wix/media'; import { auth } from '@wix/essentials'; const elevatedBulkRestoreFoldersFromTrashBin = auth.elevate(folders.bulkRestoreFoldersFromTrashBin); /* Sample folderIds value: * [ * 'd4051a6890724365a78678a6208ac37e', * '302fc049d70c41dea33fa4a27ab481ba' * ] */ async function myBulkRestoreFoldersFromTrashBinFunc(folderIds) { try { const restoredFolders = await elevatedBulkRestoreFoldersFromTrashBin(folderIds); console.log('Restored deleted folders:', restoredFolders); return restoredFolders; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ### Bulk restore (non-permanently deleted) folders ```javascript import { folders } from '@wix/media'; /* Sample folderIds value: * [ * 'd4051a6890724365a78678a6208ac37e', * '302fc049d70c41dea33fa4a27ab481ba' * ] */ async function myBulkRestoreFoldersFromTrashBinFunc(folderIds) { try { const restoredFolders = await folders.bulkRestoreFoldersFromTrashBin(folderIds); console.log('Restored deleted folders:', restoredFolders); return restoredFolders; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ### bulkRestoreFoldersFromTrashBin (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { folders } from '@wix/media'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { folders }, // Include the auth strategy and host as relevant }); async function bulkRestoreFoldersFromTrashBin(folderIds) { const response = await myWixClient.folders.bulkRestoreFoldersFromTrashBin(folderIds); }; ``` ---