> 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 # Method name: listDeletedFiles(options: ListDeletedFilesOptions) # Method package: wixMediaV2 # Method menu location: wixMediaV2 --> files --> listDeletedFiles # Method Link: https://dev.wix.com/docs/velo/apis/wix-media-v2/files/list-deleted-files.md # Method Description: Retrieves a list of files in the Media Manager's trash bin.
>**Note:** The Media Manager's trash bin (`TRASH-ROOT` folder) only contains temporarily deleted files, not permanently deleted files. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## List deleted files (dashboard page code) ```javascript import { files } from 'wix-media.v2'; async function myListDeletedFilesFunction() { try { const deletedFiles = await files.listDeletedFiles(); console.log('Files in trash:', deletedFiles) return deletedFiles; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "files": [ * { * "_createdDate": "2023-08-09T08:45:42.000Z", * "_id": "d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png", * "_updatedDate": "2023-08-09T08:45:42.000Z", * "displayName": "image1.png", * "hash": "864d607a1ea270efbac32def181f039f", * "internalTags": [ * "_fileOrigin_uploaded" * ], * "labels": [], * "media": { * "image": { * "colors": { * "palette": [ * { * "rgb": { * "b": 247, * "g": 247, * "r": 247 * } * }, * { * "rgb": { * "b": 142, * "g": 140, * "r": 140 * } * }, * { * "rgb": { * "b": 192, * "g": 218, * "r": 141 * } * }, * { * "rgb": { * "b": 195, * "g": 137, * "r": 149 * } * }, * { * "rgb": { * "b": 228, * "g": 143, * "r": 183 * } * }, * { * "rgb": { * "b": 250, * "g": 62, * "r": 152 * } * }, * { * "rgb": { * "b": 16, * "g": 16, * "r": 16 * } * }, * { * "rgb": { * "b": 140, * "g": 199, * "r": 60 * } * }, * { * "rgb": { * "b": 120, * "g": 194, * "r": 242 * } * }, * { * "rgb": { * "b": 158, * "g": 203, * "r": 103 * } * } * ], * "prominent": { * "rgb": { * "b": 247, * "g": 247, * "r": 247 * } * } * }, * "faces": [], * "image": "wix:image://v1/d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png/image1.png#originWidth=1170&originHeight=2532" * } * }, * "mediaType": "IMAGE", * "operationStatus": "READY", * "parentFolderId": "trash-root", * "private": false, * "siteId": "3ecba886-4267-11ee-be56-0242ac120002", * "sizeInBytes": "394945", * "state": "OK", * "thumbnailUrl": "https://static.wixstatic.com/media/d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png", * "url": "https://static.wixstatic.com/media/d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png" * }, * { * "_createdDate": "2023-08-09T08:45:37.000Z", * "_id": "d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg", * "_updatedDate": "2023-08-09T08:45:37.000Z", * "displayName": "vectorArt1.svg", * "hash": "e379083c3675d7f7891da00c0708539c", * "internalTags": [ * "_fileOrigin_uploaded" * ], * "labels": [], * "media": { * "image": { * "faces": [], * "image": "wix:image://v1/d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg/vectorArt1.svg#originWidth=1177&originHeight=2501" * } * }, * "mediaType": "VECTOR", * "operationStatus": "READY", * "parentFolderId": "trash-root", * "private": false, * "siteId": "3ecba886-4267-11ee-be56-0242ac120002", * "sizeInBytes": "119475", * "state": "OK", * "thumbnailUrl": "https://static.wixstatic.com/shapes/d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg", * "url": "https://static.wixstatic.com/shapes/d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg" * } * ], * "nextCursor": { * "cursors": { * "next": "" * }, * "hasNext": false * } * } */ ``` ## List deleted files (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { files } from 'wix-media.v2'; import { elevate } from 'wix-auth'; export const myListDeletedFilesFunction = webMethod(Permissions.Anyone, async () => { try { const elevatedListDeletedFiles = elevate(files.listDeletedFiles) const deletedFiles = await elevatedListDeletedFiles(); console.log('Files in trash:', deletedFiles) return deletedFiles; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "files": [ * { * "_createdDate": "2023-08-09T08:45:42.000Z", * "_id": "d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png", * "_updatedDate": "2023-08-09T08:45:42.000Z", * "displayName": "image1.png", * "hash": "864d607a1ea270efbac32def181f039f", * "internalTags": [ * "_fileOrigin_uploaded" * ], * "labels": [], * "media": { * "image": { * "colors": { * "palette": [ * { * "rgb": { * "b": 247, * "g": 247, * "r": 247 * } * }, * { * "rgb": { * "b": 142, * "g": 140, * "r": 140 * } * }, * { * "rgb": { * "b": 192, * "g": 218, * "r": 141 * } * }, * { * "rgb": { * "b": 195, * "g": 137, * "r": 149 * } * }, * { * "rgb": { * "b": 228, * "g": 143, * "r": 183 * } * }, * { * "rgb": { * "b": 250, * "g": 62, * "r": 152 * } * }, * { * "rgb": { * "b": 16, * "g": 16, * "r": 16 * } * }, * { * "rgb": { * "b": 140, * "g": 199, * "r": 60 * } * }, * { * "rgb": { * "b": 120, * "g": 194, * "r": 242 * } * }, * { * "rgb": { * "b": 158, * "g": 203, * "r": 103 * } * } * ], * "prominent": { * "rgb": { * "b": 247, * "g": 247, * "r": 247 * } * } * }, * "faces": [], * "image": "wix:image://v1/d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png/image1.png#originWidth=1170&originHeight=2532" * } * }, * "mediaType": "IMAGE", * "operationStatus": "READY", * "parentFolderId": "trash-root", * "private": false, * "siteId": "3ecba886-4267-11ee-be56-0242ac120002", * "sizeInBytes": "394945", * "state": "OK", * "thumbnailUrl": "https://static.wixstatic.com/media/d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png", * "url": "https://static.wixstatic.com/media/d4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png" * }, * { * "_createdDate": "2023-08-09T08:45:37.000Z", * "_id": "d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg", * "_updatedDate": "2023-08-09T08:45:37.000Z", * "displayName": "vectorArt1.svg", * "hash": "e379083c3675d7f7891da00c0708539c", * "internalTags": [ * "_fileOrigin_uploaded" * ], * "labels": [], * "media": { * "image": { * "faces": [], * "image": "wix:image://v1/d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg/vectorArt1.svg#originWidth=1177&originHeight=2501" * } * }, * "mediaType": "VECTOR", * "operationStatus": "READY", * "parentFolderId": "trash-root", * "private": false, * "siteId": "3ecba886-4267-11ee-be56-0242ac120002", * "sizeInBytes": "119475", * "state": "OK", * "thumbnailUrl": "https://static.wixstatic.com/shapes/d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg", * "url": "https://static.wixstatic.com/shapes/d4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg" * } * ], * "nextCursor": { * "cursors": { * "next": "" * }, * "hasNext": false * } * } */ ``` ## Bulk restores all non-permanently deleted files of chosen types ```javascript /******************************************** * Backend code - bulk-restore-files.web.js * *******************************************/ import { Permissions, webMethod } from 'wix-web-module'; import { files } from 'wix-media.v2'; import { elevate } from 'wix-auth'; export const restoreFiles = webMethod(Permissions.Anyone, async (mediaTypes) => { let idList = [] try { const options = { mediaTypes: mediaTypes }; const elevatedListDeletedFiles = elevate(files.listDeletedFiles) const deletedFiles = await elevatedListDeletedFiles(options); idList = deletedFiles.files.map((file) => { return file._id }); } catch (error) { console.error(error); } try { const elevatedBulkRestoreFilesFromTrashBin = elevate(files.bulkRestoreFilesFromTrashBin); const restoredFiles = await elevatedBulkRestoreFilesFromTrashBin(idList); console.log('Restored Files:', restoredFiles); return restoredFiles; } catch (error) { console.error(error); } }); /************* * Page code * ************/ import { restoreFiles } from 'backend/bulk-restore-files.web'; $w.onReady(() => { $w('#restoreMedia').onClick(async () => { const mediaTypes = [] if ($w('#image').checked) { mediaTypes.push("IMAGE") } if ($w('#video').checked) { mediaTypes.push("VIDEO") } if ($w('#audio').checked) { mediaTypes.push("AUDIO") } if ($w('#document').checked) { mediaTypes.push("DOCUMENT") } if ($w('#vector').checked) { mediaTypes.push("VECTOR") } if ($w('#archive').checked) { mediaTypes.push("ARCHIVE") } if ($w('#model3d').checked) { mediaTypes.push("MODEL3D") } await restoreFiles(mediaTypes); $w('#filesRestoredMsg').show(); setTimeout(() => { $w('#filesRestoredMsg').hide(); }, 5000); }); }); ``` ---