Renaming Objects

Wasabi supports functionality to move an object-in effect, renaming the object by changing the key. This eliminates the two-step process of first copying an object and then deleting the original object. The caller must have s3:PutObject policy permission on the bucket to rename objects.

To rename objects, use the HTTP method MOVE along with the following parameters in the request headers that affect the move operation.

Parameter

Description

Destination

Used to form the destination key value for moved objects. If the X-Wasabi-Prefix option is true, then all objects (including all versions) that start with the source key in the URL are renamed by first removing the source key prefix and replacing it with this destination value. Otherwise, the objects (including all versions) exactly matching the source key in the URL are renamed to the key given by the destination.

This parameter must be provided.

Overwrite

A Boolean value that, when “true,” allows overwriting destination objects with the same key. Otherwise, an error is generated and the original key is not changed.

Note that versioned buckets will always allow creating a new object version with the destination key. The default value is “false.”

X-Wasabi-Quiet

A Boolean value that, when “true,” causes the XML status return body to only display the keys that encounter errors. Otherwise, all objects renamed are given in the status. The default value is “false.”

X-Wasabi-Prefix

A Boolean value that, when “true,” means that the values given for the source in the URL and the destination are prefixes—they match the left-most part of keys. Conceptually, think of the prefix as a folder of objects. Otherwise, only the objects (including all ver­sions) that exactly match the key are renamed. The default value is “false.”

 

The call will return the results as an XML body of the response. The results include the following for each object renamed:

original source key,

renamed destination key,

version ID of the object, and

any error in the rename operation.

The quiet option will cause the results to list only the keys that encountered an error.

Below is an example, which renames all objects that start with the prefix “TestMove-Dir2/” to have the new prefix “TestMove-Dir2-Renamed/”.

MOVE http://s3.wasabisys.com/my_bucket/TestMove-Dir2/HTTP/1.1

Destination:TestMove-Dir2-Renamed/X-Wasabi-Prefix:true

Response body:

<MoveObjectResult>

   <SourcePrefix>TestMove-Dir2/</SourcePrefix>

   <DestinationPrefix>TestMove-Dir2-Renamed/</DestinationPrefix>

   <MoveObject>

      <SourceKey>TestMove-Dir2/</SourceKey>

      <DestinationKey>TestMove-Dir2-Renamed/</DestinationKey>

   </MoveObject>

   <MoveObject>

      <SourceKey>TestMove-Dir2/Dir1/</SourceKey>

      <DestinationKey>TestMove-Dir2-Renamed/Dir1/</DestinationKey>

   </MoveObject>

   <MoveObject>

      <SourceKey>TestMove-Dir2/Dir1/Obj1</SourceKey>

      <DestinationKey>TestMove-Dir2-Renamed/Dir1/Obj1</DestinationKey>

   </MoveObject>

   <MoveObject>

      <SourceKey>TestMove-Dir2/Dir1/Obj2</SourceKey>

      <DestinationKey>TestMove-Dir2-Renamed/Dir1/Obj2</DestinationKey>

   </MoveObject>

   <MoveObject>

      <SourceKey>TestMove-Dir2/Dir2/</SourceKey>

      <DestinationKey>TestMove-Dir2-Renamed/Dir2/</DestinationKey>

   </MoveObject>

   <MoveObject>

      <SourceKey>TestMove-Dir2/Dir2/Obj1</SourceKey>

      <DestinationKey>TestMove-Dir2-Renamed/Dir2/Obj1</DestinationKey>

   </MoveObject>

   <MoveObject>

      <SourceKey>TestMove-Dir2/Dir2/Obj2</SourceKey>

      <DestinationKey>TestMove-Dir2-Renamed/Dir2/Obj2</DestinationKey>

   </MoveObject>

   <MoveCount>7</MoveCount>

</MoveObjectResult>