我试图使用AWS SDK的Rails gem上传文件。
一切都成功,但我找不到使用ruby sdk将文件上传到特定文件夹的方法。
s3 = Aws::S3::Resource.new
obj = s3.bucket('storagy-teen-dev-us').object("deepak_file")
obj.upload_file('./tmp/aws_test.txt')
这很好。但我想deepak_file
在aws bucket中的特定目录中创建内部,例如photos
。我已经尝试了以下方法,但无法正常工作。
obj = s3.bucket('storagy-teen-dev-us').object("photos/deepak_file")
试试这个,
s3 = Aws::S3::Resource.new
path = 'photos/deepak_file/aws_test.txt'
s3.bucket('storagy-teen-dev-us').object(path).upload_file(./tmp/aws_test.txt)
您只需要指定带有文件名的目录的完整路径即可。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句