Restore an archived copy of an object back into an Amazon S3 bucket using an Amazon SDK - Amazon Simple Storage Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Restore an archived copy of an object back into an Amazon S3 bucket using an Amazon SDK

The following code example shows how to restore an archived copy of an object back into an S3 bucket.

Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

public static void restoreS3Object(S3Client s3, String bucketName, String keyName, String expectedBucketOwner) { try { RestoreRequest restoreRequest = RestoreRequest.builder() .days(10) .glacierJobParameters(GlacierJobParameters.builder().tier(Tier.STANDARD).build()) .build(); RestoreObjectRequest objectRequest = RestoreObjectRequest.builder() .expectedBucketOwner(expectedBucketOwner) .bucket(bucketName) .key(keyName) .restoreRequest(restoreRequest) .build(); s3.restoreObject(objectRequest); } catch (S3Exception e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
  • For API details, see RestoreObject in Amazon SDK for Java 2.x API Reference.

For a complete list of Amazon SDK developer guides and code examples, see Using this service with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.