使用activestorage的直接上传上传到S3时如何指定前缀? [英] How to specify a prefix when uploading to S3 using activestorage's direct upload?
本文介绍了使用activestorage的直接上传上传到S3时如何指定前缀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用标准的S3配置:
AWS_ACCESS_KEY_ID: [AWS ID]
AWS_BUCKET: [bucket name]
AWS_REGION: [region]
AWS_SECRET_ACCESS_KEY: [secret]
我可以使用以下Rails 5.2代码(仅显示相关代码)将文件上传到S3(使用直接上传):
I can upload a file to S3 (using direct upload) with this Rails 5.2 code (only relevant code shown):
form.file_field :my_asset, direct_upload: true
提交表格后,这将有效地将我的资产放在S3存储桶的根中.
This will effectively put my asset in the root of my S3 bucket, upon submitting the form.
如何指定前缀(例如"development/",以便模仿S3上的文件夹)?
How can I specify a prefix (e.g. "development/", so that I can mimic a folder on S3)?
推荐答案
对不起,目前无法实现.我建议创建一个供Active Storage专用的存储桶.
Sorry, that’s not currently possible. I’d suggest creating a bucket for Active Storage to use exclusively.
这篇关于使用activestorage的直接上传上传到S3时如何指定前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文