Copying an Object to Another Bucket in Object Storage

Copy an object to another bucket in Object Storage.

Caution

Object copy doesn't work if you don't authorize the Object Storage service to copy objects on your behalf. See Service Permissions for more information.

Copy Object Overwrite Rules

Use overwrite rules to control the copying of objects based on their entity tag (ETag) values.

  • Overwrite destination object: Use this option when you don't want to limit a copy operation by an ETag value. This option is the default. This option can be used for any copy operation, regardless of whether it involves overwriting an existing object.

  • Do not overwrite any destination object: Use this option to prevent the overwriting an existing copy of an object in the destination location, regardless of the destination object's ETag value.

  • Overwrite destination object only if it matches the specified ETag: Use this option to prevent the accidental overwriting of an object in the destination location that doesn't have the specified ETag. When you use this option, the copy operation only succeeds if the ETag you supply when starting the copy request matches the ETag of the destination object.

  • Copy object only if the source matches the specified ETag: Use this option if you want the copy operation successful only if the ETag you supply when starting the copy request matches the ETag of the source object. For objects that are intentionally updated and overwritten as part of data management activity, this option ensures that only the specified version of the object (as indicated by the ETag) is allowed to be copied. If the object's ETag value changes after the copy work request is created, but before the copy operation is run, the copy operation doesn't complete.

Caution

If you overwrite an object, the operation can't be undone.

Scope and Constraints

  • Objects can't be copied directly from Archive Storage. To copy objects that are in Archive Storage, you must first restore the object to the Standard Object Storage tier. Objects can be copied directly to Archive tier buckets from the Standard or Infrequent Access tiers. When you copy objects into an Archive Storage bucket, the copy of the object is immediately archived.

  • Specify an existing target bucket for the copy request. The copy operation doesn't automatically create buckets.

  • When an object is copied, the destination object receives a new ETag value.

  • If you rename, overwrite, or delete a source object during a copy operation, the copy operation fails and the destination object is not created or overwritten.

  • Bulk copying isn't supported. Identify a single object in the copy request.

Service Permissions

Because Object Storage is a regional service, you must authorize the Object Storage service for each region carrying out copy operations on your behalf. For example, you might authorize the Object Storage service in region US East (Ashburn) to manage objects on your behalf. After you authorize the Object Storage service, you can copy an object stored in a US East (Ashburn) bucket to a bucket in another region.

To determine the region identifier value of an Oracle Cloud Infrastructure region, see Regions and Availability Domains.

For administrators:

To enable object copy, you must authorize the service to manage objects on your behalf:

  • You can create a policy that authorizes the service in the specified region to manage Object Storage namespaces, buckets, and their associated objects in all compartments in the tenancy:

    Allow service objectstorage-<region_identifier> to manage object-family in tenancy
  • Instead of using the policy verb manage, you can create a policy that reduces the scope of access by instead using one of the following statements:

    Allow service objectstorage-<region_identifier> to manage object-family in tenancy where any {request.permission='OBJECT_READ', request.permission='OBJECT_INSPECT', request.permission='OBJECT_CREATE', request.permission='OBJECT_OVERWRITE', request.permission='OBJECT_DELETE'}
    Allow service objectstorage-<region_identifier> to manage object-family in compartment <compartment_name> where any {request.permission='OBJECT_READ', request.permission='OBJECT_INSPECT', request.permission='OBJECT_CREATE', request.permission='OBJECT_OVERWRITE', request.permission='OBJECT_DELETE'}

Copying an Object

    1. Open the navigation menu and click Storage. Under Object Storage & Archive Storage, click Buckets.
    2. Select the compartment from the list under List Scope. All buckets in that compartment are listed in tabular form.
    3. Click the bucket containing the object you want to copy. The bucket's Details page appears.
    4. Click Objects under Resources. The Objects list appears. All objects in the bucket are displayed in tabular form.
    5. Click the Actions menu (Actions Menu) next to object that you want to copy (the source object), and select Copy. The Copy Object dialog box appears.

      The Console checks the IAM policies that are in place to perform this task successfully. If you see a policy missing warning, you can let the Console try to create any missing policies or copy the missing policy details to the clipboard to email your administrator. If you think you have the required policies in place, go ahead and try the copy operation.

    6. Complete the following:
      • Destination Namespace: Enter the namespace of the destination bucket for the copied object. The namespace string of your tenancy is supplied as the default value. See Understanding Namespaces for more information.

      • Destination Region: Select the OCI region that contains the destination bucket for the copied object from the list. Your tenancy must be subscribed to a region for you to copy an object to a bucket in that region.

      • Destination Bucket: Enter the name of the destination bucket for the copied object. The destination must be an existing bucket in that you have access to. See Buckets for more information on how to create a bucket.

      • Destination Object Name: (Optional) Enter an alternate name for the object being copied if you don't want to use its original name. By default, the name is the same name as the object that you're copying.

      • Destination Storage Tier: (Optional) Specify the storage tier to upload the object to if you want it to be different than the source storage tier. The following storage tiers are supported:

        If you don't specify a destination storage tier, the object is stored in the same storage tier as the bucket. See Understanding Storage Tiers for more information.

      • Overwrite Rule: Select the overwrite rule appropriate for the copy request:

        • Overwrite destination object

        • Do not overwrite any destination object

        • Overwrite destination object only if it matches the specified ETag

        • Copy object only if the source matches the specified ETag

        See Copy Object Overwrite Rules for descriptions of each of these rules.

    7. Click Copy Object.

    The Work Request Details dialog box appears and confirms that the copy request is submitted successfully and tracks the status of the request.

  • Use the oci os object copy command and required parameters to copy an object to another bucket:

    oci os object copy --bucket-name source_bucket_name --source-object-name source_object_name --destination-bucket destination_bucket_name [OPTIONS]

    For example:

    oci os object copy --bucket-name photos --source-object-name hummingbird.jpg --destination-namespace ansh8lvru1zp --destination-bucket UK_photos
    Copying an Object to a Different Region

    Include the destination-region parameter and the region identifier to specify a target bucket in region on there than the one where the destination object resides.

    For example:

    oci os object copy --bucket-name photos --source-object-name hummingbird.jpg --destination-bucket UK_photos --destination-region uk-london-1
    Your tenancy must be subscribed to a region for you to copy an object to a bucket in that region.
    Copying to a Different Destination Storage Tier

    Include the destination-object-storage-tier parameter and a supported storage tier value to copy the object to a different storage tier on the destination bucket than the tier where it resides on the source.

    For example:

    oci os object copy --bucket-name photos --source-object-name hummingbird.jpg --destination-bucket UK_photos --destination-object-storage-tier Archive

    Supported values are:

    • Standard (default)

    • InfrequentAccess

    • Archive

    • If you don't specify a destination storage tier, the object is stored in the same storage tier as the bucket. See Understanding Storage Tiers for more information.

    Specifying the Namespace of the Copied Object

    Include the destination-namespace parameter and its value to specify the destination namespace to which the object is copied.

    For example:

    oci os object copy --bucket-name photos --source-object-name hummingbird.jpg --destination-bucket UK_photos --destination-namespace MyNamespace
    See Understanding Namespaces for more information.
    Specifying an Alternate Name for the Copied Object

    Include the destination-object-name parameter and its value to apply an alternate name to the copied object.

    For example:

    oci os object copy --bucket-name photos --source-object-name hummingbird.jpg --destination-bucket UK_photos --destination-object-name hummingbird_brochure.jpg

    By default, the name is the same name as the object that you're copying.

    For a complete list of parameters and values for CLI commands, see the CLI Command Reference.

  • Run the CopyObject operation to copy an object to another bucket.