Skip to content

Deleting a File

To delete a file from the Backendless file storage, it must be identified by the file path/name. Files in the Backendless storage have the following URL structure:

https://api.backendless.com/<application id>/<REST API key>/files/<path>/<file name>

The API to delete a file uses the <path>/<filename> part to identify the file which must be deleted.

- (void)removeWithPath:(NSString * _Nonnull)path responseHandler:^(void)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;

- (void)removeWithPath:(NSString * _Nonnull)path pattern:(NSString * _Nonnull)pattern recursive:(BOOL)recursive responseHandler:^(void)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func remove(path: String, responseHandler: (() -> Void)!, errorHandler: ((Fault) -> Void)!)

func remove(path: String, pattern: String, recursive: Bool, responseHandler: (() -> Void)!, errorHandler: ((Fault) -> Void)!)

where:

Argument                Description
path Path of the file to delete. The path must consist of the file path and file name.

Example

[Backendless.shared.file removeWithPath:@"myfiles/myhelloworld-sync.txt" responseHandler:^{
    NSLog(@"File has been removed");
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
Backendless.shared.file.remove(path: "myfiles/myhelloworld-sync.txt", responseHandler: {
    print("File has been removed")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

Codeless Reference

files_api_delete_file_1

where:

Argument                Description
file path A path identifying a directory where a file must be deleted. The path must start with the root directory of the remote file storage.

This operation does not return a value.

Consider the following file stored in the notes directory:

files_api_delete_file_2

The example below deletes the "grocery.txt" file from the "notes" directory.

files_api_delete_file_3