Restores the specified files from the Media Manager's trash bin, and moves them to their original locations in the Media Manager.
The bulkRestoreFilesFromTrashBin()
function returns a Promise that resolves when the files have been restored.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function bulkRestoreFilesFromTrashBin(fileIds: Array<string>): Promise<void>;
IDs of the files to restore from the Media Manager's trash bin.
You can also pass the files' Wix media URLs. For example, ["wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032"]
.
Learn more in the File and Folder IDs article.
import { files } from "wix-media.v2";
/* Sample fileIds value:
* [
* 'd4dde1_dee18c9ada174a818ccf75c50e72c739~mv2.jpg',
* 'd4dde1_32288e20a5aa4213a52b15426fb27c9f~mv2.png',
* 'd4dde1_8dd2bfe6121f43b29ebeaa63988abf54.svg'
* ]
*/
async function myBulkRestoreFilesFromTrashBinFunction(fileIds) {
try {
const restoredFiles = await files.bulkRestoreFilesFromTrashBin(fileIds);
console.log("Restored Files:", restoredFiles);
return restoredFiles;
} catch (error) {
console.error(error);
}
}
/* Promise resolves to void */
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.