Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I rename a file with Fog?

I have a rails 3.2 app. Using fog to store files in S3.

I would like to write a script to rename all of the files that have been uploaded. I can't seem to find any fog documentation in this area.

Is this possible with fog? Do I need another gem?

like image 226
BM5k Avatar asked Dec 20 '12 21:12

BM5k


1 Answers

What about copying as mentioned in this post? cf. fog's requests sources and fog's models sources.

You should be able to do:

storage.copy_object('old_bucket', 'old_filename', 'new_bucket', 'new_filename')

or

file.copy('new_bucket', 'new_filename')

Destroying the original file after a successful copy remains necessary though.

like image 92
Dirty Henry Avatar answered Oct 12 '22 08:10

Dirty Henry