我正在使用神社直接上传到aws-s3
存储桶并且工作正常。现在我想改用 DigitalOcean spaces
。所以我改变了一些神社的设置,如下所示(只改变了env
与空格相关的变量)。
require "shrine"
require "shrine/storage/s3"
s3_options = {
access_key_id: ENV["SPACES_ACCESS_KEY_ID"],
secret_access_key: ENV["SPACES_SECRET_ACCESS_KEY"],
region: ENV["SPACES_REGION"],
bucket: ENV["SPACES_BUCKET"],
endpoint: ENV["SPACES_ENDPOINT"]
}
Shrine.storages = {
cache: Shrine::Storage::S3.new(prefix: "cache", upload_options: {acl: "public-read"}, **s3_options),
store: Shrine::Storage::S3.new(prefix: "store", upload_options: {acl: "public-read"}, **s3_options),
}
Shrine.plugin :activerecord
Shrine.plugin :presign_endpoint
Shrine.plugin :restore_cached_data
Shrine.plugin :backgrounding
Shrine::Attacher.promote {|data| UploadJob.perform_async(data)}
Shrine::Attacher.delete {|data| DeleteJob.perform_async(data)}
我还在空格中添加了 cors 以允许所有请求,如下所示
但是当我上传时,我收到了这个错误。
<Error><Code>AccessDenied</Code><Message>Policy missing condition: Content-Type</Message><BucketName>testing-dev</BucketName><RequestId>tx0000000036366363370-3663t37373-33883-sgp1a</RequestId><HostId>349494-sgp1a-sgp</HostId></Error>
这里可能是什么问题?我可以看到content-type
策略中缺少错误提示。但是,如果是这样,我该如何添加呢?