Copy file

Copy file API

POST https://api.imagekit.io/v1/files/copy

This will copy a file from one folder to another. Note: If any file at the destination has the same name as the source file, then the source file and its versions (if includeFileVersions is set to true) will be appended to the destination file version history.

Headers

NameTypeDescription

Authorization

string

base64 encoding of your_private_api_key:

Note the colon in the end.

Request Body

NameTypeDescription

sourceFilePath

string

The full path of the file you want to copy. For example - /path/to/file.jpg

destinationPath

string

Full path to the folder you want to copy the above file into. For example - /folder/to/copy/into/

includeFileVersions

boolean

Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied.

Default value - false

Response structure and status code

In case of an error, you will get an error code along with the error message. On success, you will receive a 204 status code with an empty body.

Access control and permissions

Read how access and permissions are affected by this operation here.

Examples

Here is the example request to understand the API usage.

curl -X POST "https://api.imagekit.io/v1/files/copy" \
-H 'Content-Type: application/json' \
-u your_private_key: -d '
{
	"sourceFilePath" : "/path/to/file.jpg",
	"destinationPath" : "/folder/to/copy/into/",
    "includeFileVersions" : true
}
'

Last updated