Restore archived storage class files
Restore archived class files
When a user uploads an archived file, it enters a frozen state. To download it, the archived file must first be restored. The requester must have read permissions for the archived file, and the file must remain in its frozen state.
Examples of restoring archived files are as follows:
1# Restore the archived file and set the duration after restoring to 2 days
2bos_client.restore_object(bucket_name, target_key)
| Parameters | Types | Description | Required or not |
|---|---|---|---|
| days | int | Defines the duration of the restored state in days, with a numeric value greater than 0 and less than 30. By default, the restoration duration is 7 days, with a maximum duration of 30 days. | No |
| tier | string | Restore priority. The available values are as follows:
|
No |
Check whether the archived file has been restored
For archive storage objects, if they are being restored or have been restored, bce_restore will be returned when obtaining ObjectMetadata. For archived objects being restored, the value of bce_restore is ongoing-request="true"; for archived objects that have been retrieved, the value of bce_restore is ongoing-request="false", expiry-date="Wed, 07 Nov 2019 00:00:00 GMT". Where, expiry-date represents the expiration time after the object is restored.
An example is as follows:
1response = bos_client.get_object_meta_data(bucket_name, object_key)
2if response.metadata.bce_restore is not None:
3 if response.metadata.bce_restore.find("expiry-date") >= 0:
4 print("archive object is restored.")
5 else:
6 print("archive object is restoring.")
7else:
8 print("archvie object is freezed.")
