Home > Software engineering >  AWS S3: can I move object within a bucket by changing its key?
AWS S3: can I move object within a bucket by changing its key?

Time:12-01

I have a javascript lambda function that is triggered by file upload, reads the content, validates, converts data records contained therein into an array and puts data into a DynamoDB table. When everything is OK, the file (S3 object) is moved to another folder in the same bucket - the function copies the original object to another folder and deletes the original. This action takes some time and generates "unnecessary" data transfer. Is there a possibility to "modify" the object key, effectively moving it?

CodePudding user response:

Amazon S3 does not have a 'rename' or 'modify' function. All objects are immutable and the Key cannot be changed -- it is the unique identifier of the object.

To 'move' an object, the correct process is to CopyObject() and then DeleteObject(). This creates a new object with the desired Key.

  • Related