Examples
Here are some examples to understand the API usage.
curl -X PUT "https://api.imagekit.io/v1/files/rename" \ -H 'Content-Type: application/json' \ -u your_private_key: -d ' { "filePath" : "/path/to/old-file-name.jpg", "newFileName" : "new-file-name.jpg", "purgeCache": false } '
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.renameFile( { filePath: "/path/to/old-file-name.jpg", newFileName: "new-file-name.jpg", purgeCache: 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/' ) rename_file = imagekit.rename_file(options=RenameFileRequestOptions(file_path="/file_path.jpg", new_file_name="new_file_name.jpg", purge_cache=True)) print("Rename file-", rename_file, end="\n\n") # Raw Response print(rename_file.response_metadata.raw) # print the purge request id print(rename_file.purge_request_id)
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 ); $filePath='/path/to/old-file-name.jpg'; $newFileName = 'new-file-name.jpg'; $renameFile = $imageKit->rename([ 'filePath' => $filePath, 'newFileName' => $newFileName, 'purgeCache' => false, // optional ]); echo("Rename File : " . json_encode($renameFile));
RenameFileRequest renameFileRequest = new RenameFileRequest(); renameFileRequest.setFilePath("/path/to/old-file-name.jpg"); renameFileRequest.setNewFileName("new-file-name.jpg"); renameFileRequest.setPurgeCache(false); ResultRenameFile resultRenameFile = ImageKit.getInstance().renameFile(renameFileRequest);
imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint") imagekitio.rename_file( file_path: '/path/to/old-file-name.jpg', new_file_name: 'new-file-name.jpg', purge_cache: false #optional )
resp, err := ik.Media.RenameFile(ctx, media.RenameFileParam{ FilePath: "/path/to/old-file-name.jpg", NewFileName: "new-file-name.jpg", PurgeCache: false, // Optional })
var imagekit = new ImageKit({ publicKey : "your_public_api_key", privateKey : "your_private_api_key", urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/" }); RenameFileRequest renameFileRequest = new RenameFileRequest { filePath = "path_1", newFileName = "file_name", purgeCache = false }; ResultRenameFile resultRenameFile = imagekit.RenameFile(renameFileRequest);