Copy file
post
https://api.imagekit.io
/v1/files/copy
Copy file API
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.Here is the example request to understand the API usage.
cURL
Node.js
Python
PHP
Java
Ruby
Go
.Net
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
}
'
var ImageKit = require("imagekit");
var imagekit = new ImageKit({
publicKey : "your_public_api_key",
privateKey : "your_private_api_key",
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
imagekit.copyFile({
sourceFilePath: "/path/to/file.jpg",
destinationPath: "/folder/to/copy/into/",
includeFileVersions: false // optional
}, function(error, result) {
if(error) console.log(error);
else console.log(result);
});
from imagekitio import ImageKit
imagekit = ImageKit(
public_key='your_public_api_key',
private_key='your_private_api_key',
url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/'
)
copy_file = imagekit.copy_file(options=CopyFileRequestOptions(source_file_path="/file.jpg",
destination_path="/test",
include_file_versions=True))
print("Copy file-", copy_file, end="\n\n")
# Raw Response
print(copy_file.response_metadata.raw)
use ImageKit\ImageKit;
$public_key = "your_public_api_key";
$your_private_key = "your_private_api_key";
$url_end_point = "https://ik.imagekit.io/your_imagekit_id";
$imageKit = new ImageKit(
$public_key,
$your_private_key,
$url_end_point
);
$destinationPath = '/destination-folder';
$copyFile = $imageKit->copy([
'sourceFilePath' => '/pah/to/file.jpg',
'destinationPath' => '/folder/to/copy/into/',
'includeFileVersions' => false
]);
echo("Copy File : " . json_encode($copyFile));
CopyFileRequest copyFileRequest = new CopyFileRequest();
copyFileRequest.setSourceFilePath("/path/to/file.jpg");
copyFileRequest.setDestinationPath("/folder/to/copy/into/");
copyFileRequest.setIncludeFileVersions(true);
ResultNoContent resultNoContent = ImageKit.getInstance().copyFile(copyFileRequest);
imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint")
imagekitio.copy_file(
source_file_path: '/pah/to/file.jpg',
destination_path: '/folder/to/copy/into/',
include_file_versions: false # optional
)
resp, err := ik.Media.CopyFile(ctx, media.CopyFileParam{
SourcePath: "/path/to/file.jpg",
DestinationPath: "/folder/to/copy/into/",
IncludeVersions: false, //optional
})
var imagekit = new ImageKit({
publicKey : "your_public_api_key",
privateKey : "your_private_api_key",
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
CopyFileRequest cpyRequest = new CopyFileRequest
{
sourceFilePath = "/path/to/file.jpg",
destinationPath = "/folder/to/copy/into/"
};
ResultNoContent resultNoContent = imagekit.CopyFile(cpyRequest);
Last modified 14d ago