我一直在 Rails 5.2 上实施 Active Storage Google 策略,目前我可以毫无问题地使用 rails 控制台上传文件,我唯一缺少的是是否有一种方法可以指定存储桶内的目录。现在我上传如下
bk.file.attach(io: File.open(bk.source_dir.to_s), filename: "file.tar.gz", content_type: "application/x-tar")
我的 storage.yml 上的配置
google:
service: GCS
project: my-project
credentials: <%= Rails.root.join("config/myfile.json") %>
bucket: bucketname
但是在我的存储桶中有不同的目录,例如 bucketname/department1 等。我浏览了文档,但没有找到指定更多目录的方法,我所有的上传都以存储桶名称结尾。