Restore file version
put
https://api.imagekit.io
/v1/files/:fileId/versions/:versionId/restore
Restore file version API
In case of an error, you will get an error code along with the error message. On success, you will receive a
200
status code with the file object in JSON-encoded response body.Here is the example request to understand the API usage.
cURL
Node.js
Python
PHP
java
Ruby
.Net
# The unique fileId and versionId of the uploaded file. fileId and versionId (versionInfo.id) is returned in response of list files API and upload API.
curl -X PUT "https://api.imagekit.io/v1/files/file_id/versions/version_id/restore" \
-u your_private_api_key:
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.restoreFileVersion({
fileId: "file_id",
versionId: "version_id"
}, 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/'
)
restore_file_version = imagekit.restore_file_version(file_id="file_id", version_id="version_id")
print("Restore file version-", restore_file_version, end="\n\n")
# Raw Response
print(restore_file_version.response_metadata.raw)
# print that file's id
print(restore_file_version.file_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
);
$fileId = 'file_id';
$versionId = 'version_id';
$restoreFileVersion = $imageKit->restoreFileVersion([
'fileId' => $fileId,
'versionId' => $versionId,
]);
echo("Restore File Version : " . json_encode($restoreFileVersion));
Result result = ImageKit.getInstance().restoreFileVersion("file_id", "version_id");
imagekitio.restore_file_version(
file_id: 'file_id',
version_id: 'version_id'
)
var imagekit = new ImageKit({
publicKey : "your_public_api_key",
privateKey : "your_private_api_key",
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
Result result = imagekit.RestoreFileVersion("file_Id", "version_Id");
Last modified 6mo ago