The file storage provider entity containing connection details
The key or name of the file to delete (use the ProviderKey if it was returned during upload, otherwise use the file Name)
A promise that resolves to a boolean indicating whether the deletion was successful
// Delete a file from storage
const fileStorageProvider = await entityMgr.FindById('FileStorageProvider', 'azure-main');
// Delete using the file name
const deleted = await deleteObject(fileStorageProvider, 'temp/obsolete-document.pdf');
// Or using the provider key if returned during upload
const deleted = await deleteObject(fileStorageProvider, file.ProviderKey);
if (deleted) {
console.log('File successfully deleted');
} else {
console.log('Failed to delete file - it may not exist or there was an error');
}
Deletes a file from the specified file storage provider.
This utility function handles file deletion by instantiating the appropriate storage provider driver and delegating to its DeleteObject method. It provides a simple way to remove files that are no longer needed.