Đây là Fog walkthrough of creating a file (an S3 object) in a directory (an S3 bucket):Làm thế nào để tạo một đối tượng S3 trong một xô với một cuộc gọi Sương mù?
connection = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => YOUR_AWS_ACCESS_KEY_ID,
:aws_secret_access_key => YOUR_AWS_SECRET_ACCESS_KEY
})
directory = connection.directories.create(
:key => "fog-demo-#{Time.now.to_i}", # globally unique name
:public => true
)
file = directory.files.create(
:key => 'resume.html',
:body => File.open("/path/to/my/resume.html"),
:public => true
)
Nhưng có vẻ với tôi như thể điều này đòi hỏi 2 cuộc gọi API:
connection.directories.create
directory.files.create
Nếu tôi đã có thư mục (một thùng S3) được tạo, làm cách nào để tạo một tệp (đối tượng S3) chỉ với một cuộc gọi Sương mù?
Điều này cần quyền truy cập khác nhau mặc dù: * ListAllMyBuckets * và * GetBucketLocation * trên tất cả các nhóm. – schmijos
@JosuaSchmid Tốt bắt! :) – facundofarias
Điều này làm cho một yêu cầu thêm không cần thiết. – mipmip