Skip to content

Moving a File/Directory

- (void)moveWithSourcePath:(NSString * _Nonnull)sourcePath targetPath:(NSString * _Nonnull)targetPath responseHandler:^(NSString * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func move(sourcePath: String, targetPath: String, responseHandler: ((String) -> Void)!, errorHandler: ((Fault) -> Void)!)

where:

Argument                Description
sourcePath a path identifying file or directory to move. The path must start with the root directory of the remote file storage.
targetPath a path to a directory where the source file or directory should be moved to. If the directory does not exist, it is created.

Return value

Absolute path to the copied file or directory.

Example

The example below describes how to move a file called readme.txt located in the /documentationdirectory to the /updated-docs directory:

[Backendless.shared.file moveWithSourcePath:@"documentation/readme.txt" targetPath:@"updated-docs" responseHandler:^(NSString *filePath) {
    NSLog(@"File has been moved: %@", filePath);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
Backendless.shared.file.move(sourcePath: "documentation/readme.txt", targetPath: "updated-docs", responseHandler: { filePath in
    print("File has been moved: \(filePath)")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})

Errors

The server may return the following errors:

Error Code
Error message
Notes
4000
User has no permissions to specified resource
Occurs when the user (anonymous or logged in) has no permission to modify the file
6000
File or directory cannot be found.
Occurs when the source file/directory cannot be found.
6006
Path contains prohibited symbols: {path name}

6007
The specified resource was not found
Occurs when the API requests to rename a non-existent file or a directory.
6018
Unable to modify file/folder: file/folder already exists: {file/directory name}
Occurs when the target file/directory already exists.
6021
Unable to move file to file

6023
File already exists in target directory

6028
Parameter {param name} cannot be null
Occurs when one of the parameters is null.
8010
Missing field {field name}
Occurs in REST APIs when one of the required fields is missing in the body.
8011
Content type should be 'application/json'
Occurs in REST API when the request's content type is not application/json