【发布时间】:2014-01-07 03:06:31
【问题描述】:
有没有办法使用aws-ruby-sdk gem 上传文件但具有动态(自定义)文件名?这似乎是一个显而易见的需求,但在documentation 中却找不到它。呜呜呜
我在文档中看到的唯一方法如下,它没有提供太大的灵活性。
## Uploading Files
## You can upload a file to S3 in a variety of ways. Given a path to a file (as a string) you can do any of the following:
# specify the data as a path to a file
obj.write(Pathname.new(path_to_file))
# also works this way
obj.write(:file => path_to_file)
# Also accepts an open file object
file = File.open(path_to_file, 'rb')
obj.write(file)
## All three examples above produce the same result. The file will be streamed to S3 in chunks. It will not be loaded entirely into memory.
到目前为止,我一直在使用 aws-s3 gem,它支持 AWS::S3::S3Object.store,但现在我使用的是 SDK gem,我不能同时使用它。
【问题讨论】:
标签: ruby-on-rails ruby amazon-web-services amazon-s3