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:<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)!)


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


[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



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:


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