Deletes the specified files from the Media Manager.
The bulkDeleteFiles()
function returns a Promise that resolves when the files are deleted.
The deleted files are moved to the Media Manager's trash bin (TRASH_ROOT
folder) unless permanently deleted. To permanently delete files, pass the permanent
parameter with the value true
. Permanently deleting files isn't reversible, so make sure that these files aren't being used in a site or in any other way as the files will no longer be accessible.
Notes:
bulkRestoreFilesFromTrashBin()
to restore files from the Media Manager's trash bin.This function requires elevated permissions and runs only on the backend and on dashboard pages.
function bulkDeleteFiles(
fileIds: Array<string>,
options: BulkDeleteFilesOptions,
): Promise<void>;
IDs of the files to move to 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.
Options to use when deleting files.
import { files } from "wix-media.v2";
/* Sample fileIds value:
* [
* 'w8ide0_v12i2pi4549locqdfeb5yy5b8iyh39az.pdf',
* 'w8ide0_ye3x8yyf5izwe01ovn682pa76bzrrcyt.pdf'
* ]
*
* Sample options value:
* {
* permanent: true
* }
*/
async function myBulkDeleteFilesFunction(fileIds, options) {
try {
await files.bulkDeleteFiles(fileIds, options);
console.log("Permanently deleted files.");
return;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to void */
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.