Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Amazon S3 Essentials

You're reading from   Amazon S3 Essentials Get started with Amazon S3 for virtually unlimited cloud and Internet storage

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher Packt
ISBN-13 9781783554898
Length 112 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Sunil Gulabani Sunil Gulabani
Author Profile Icon Sunil Gulabani
Sunil Gulabani
Arrow right icon
View More author details
Toc

Copying objects


Amazon S3 SDK provides a copy object functionality that allows you to copy Amazon S3 objects from one bucket to another. For this, you have to define the source bucket name, source object key, destination bucket name, and the destination object key. The following is the API that we can use to copy the object:

public void copyObjects1(String sourceBucketName, String sourceObjectKey, String destinationBucketName, String destinationObjectKey){
    System.out.println("================ COPY OBJECT ================ ");
    try {
      s3.copyObject(sourceBucketName, sourceObjectKey, destinationBucketName, destinationObjectKey);
    } catch (AmazonServiceException exception) {
      exception.printStackTrace();
    } catch (AmazonClientException exception) {
      exception.printStackTrace();
    }
  }

We can also copy objects using the CopyObjectRequest class. This is used when we want to add the metadata of a newly copied object along with CannedAccessControlList and constraints...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime