Help Center> Object Storage Service> SDK Reference> .NET> Versioning Management> Restoring an Archive Object with a Specified Version ID

Restoring an Archive Object with a Specified Version ID

If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see the API Reference

You can call ObsClient.RestoreObject to pass the version ID (VersionId) to restore an Archive object. Sample code is as follows:

// Create an instance of ObsClient.
ObsClient client = new ObsClient("*** Provide your Access Key ***", "*** Provide your Secret Key ***", "https://your-endpoint");
// Restore a versioning Archive object.
try
{
    RestoreObjectRequest request = new RestoreObjectRequest();
    request.BucketName = "bucektname";
    request.ObjectKey = "objectname";
    request.Days = 5;
    // Restore a versioning object in the Expedited mode.
    request.Tier = RestoreTierEnum.Expedited;
    request.VersionId = "versionId";
    RestoreObjectResponse response = client.RestoreObject(request);
    Console.WriteLine("Restore object response: {0}", response.StatusCode);
}
catch (ObsException ex)
{
    Console.WriteLine("ErrorCode: {0}", ex.ErrorCode);
    Console.WriteLine("ErrorMessage: {0}", ex.ErrorMessage);
}