0

I have a file present inside IN folder on S3 bucket with key as in/c05cf611db4b4a72a8a254fcf4355fb7-sample1.csv". Now I want to move this file inside another folder ARCHIEVE_IN so that it's key changes to archieve_in/c05cf611db4b4a72a8a254fcf4355fb7-sample1.csv".

Is there a way to achieve this functionality with the ex_aws library.

chandradot99
  • 3,616
  • 6
  • 27
  • 45
  • I don't think you can rename a file in S3: https://stackoverflow.com/questions/21184720/how-to-rename-files-and-folder-in-amazon-s3. You'll need to copy and delete. – Dogbert Apr 04 '18 at 06:26
  • @Dogbert yes I think you are right, the only way to do so is to download the file, change it's name, upload it again, then delete the original file. – chandradot99 Apr 04 '18 at 06:37
  • Possible duplicate of [How to rename files and folder in Amazon S3?](https://stackoverflow.com/questions/21184720/how-to-rename-files-and-folder-in-amazon-s3) – salvatore Feb 02 '19 at 07:19

1 Answers1

1

S3 doesn't have a built in "move" operation. You can instead use ExAws.S3.put_object_copy to copy the file to a new place and then ExAws.S3.delete_object to delete the old file.

Dogbert
  • 212,659
  • 41
  • 396
  • 397