本文介绍了如何使用 Fog 重命名文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 rails 3.2 应用程序.使用雾在 S3 中存储文件.
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?
推荐答案
坏消息是你需要做一个 get/create/destroy
The bad news is you need to do a get/create/destroy
foo = bucket.files.get 'foo'
bar = bucket.files.create :key => 'bar', :body => foo.body
foo.destroy
好消息是,如果您是从同一地区的 ec2 执行此操作,它可能会像在本地计算机上重命名文件一样快
The good news is if you're doing it from ec2 in the same region it will probably happen as fast as renaming a file on your local computer
这篇关于如何使用 Fog 重命名文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!