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 ?? "")")
})