Skip to content

Copying a File/Directory

Backendless.Files.copyFile(sourcePath, targetPath)
 .then( function( filePath ) {
 .catch( function( error ) {


Argument                Description
sourcePath a path identifying file or directory to be copied. 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 copied to. If the directory does not exist, it is created.

Return value

Absolute path to the copied file or directory.


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

Backendless.Files.copyFile( "/documentation/readme.txt", "/updated-docs" )
 .then( function( filePath ) {
    console.log( "file has been copied. File path - " + filePath );
 .catch( function( error ) {
    console.log(  "error - " + error.message );


The server may return the following errors:

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

The specified resource was not found
Occurs when the API requests to rename a non-existent file or a directory.
Unable to modify file/folder: file/folder already exists: {file/directory name}
Occurs when the target file/directory already exists.
Parameter {param name} cannot be null
Occurs when one of the parameters is null.
Missing field {field name}
Occurs in REST APIs when one of the required fields is missing in the body.
Content type should be 'application/json'
Occurs in REST API when the request's content type is not application/json