Ensure public-read ACL for S3 service with public mode.

This commit is contained in:
Jason Lee 2019-10-17 15:24:00 +08:00
parent 7fd5ca79a5
commit 5ae3b01e97
2 changed files with 7 additions and 1 deletions

View File

@ -17,8 +17,10 @@ module ActiveStorage
@bucket = @client.bucket(bucket)
@multipart_upload_threshold = upload.fetch(:multipart_threshold, 100.megabytes)
@upload_options = upload
@public = public
@upload_options = upload
@upload_options[:acl] = "public-read" if public?
end
def upload(key, io, checksum: nil, filename: nil, content_type: nil, disposition: nil, **)

View File

@ -10,6 +10,10 @@ if SERVICE_CONFIGURATIONS[:s3_public]
include ActiveStorage::Service::SharedServiceTests
test "public acl options" do
assert_equal "public-read", @service.upload_options[:acl]
end
test "public URL generation" do
url = @service.url(@key, filename: ActiveStorage::Filename.new("avatar.png"))