Member Junction
    Preparing search index...

    Variable deleteObjectConst

    deleteObject: (
        providerEntity: MJFileStorageProviderEntity,
        providerKeyOrName: string,
        userContext?: UserContextOptions,
    ) => Promise<boolean> = DeleteObject

    Type Declaration

      • (
            providerEntity: MJFileStorageProviderEntity,
            providerKeyOrName: string,
            userContext?: UserContextOptions,
        ): Promise<boolean>
      • 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.

        Parameters

        • providerEntity: MJFileStorageProviderEntity

          The file storage provider entity containing connection details

        • providerKeyOrName: string

          The key or name of the file to delete (use the ProviderKey if it was returned during upload, otherwise use the file Name)

        • OptionaluserContext: UserContextOptions

          Optional user context for OAuth providers (required if provider.RequiresOAuth is true)

        Returns Promise<boolean>

        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', userContext);

        // Or using the provider key if returned during upload
        const deleted = await deleteObject(fileStorageProvider, file.ProviderKey, userContext);

        if (deleted) {
        console.log('File successfully deleted');
        } else {
        console.log('Failed to delete file - it may not exist or there was an error');
        }

    Use DeleteObject.