Skip to content

Commit

Permalink
GCS: pass acl_header for public read if fog is public
Browse files Browse the repository at this point in the history
If not done, uploading a file via carrierwave with fog_public will return access denied.

Closes #2426
  • Loading branch information
yosiat committed Dec 30, 2020
1 parent 3084b24 commit 92a69de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/carrierwave/storage/fog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ def file
def acl_header
if fog_provider == 'AWS'
{ 'x-amz-acl' => @uploader.fog_public ? 'public-read' : 'private' }
elsif fog_provider == "Google"
@uploader.fog_public ? { destination_predefined_acl: "publicRead" } : {}
else
{}
end
Expand Down
3 changes: 3 additions & 0 deletions spec/storage/fog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def check_file
if @provider == 'AWS'
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything, { "x-amz-acl"=>"public-read" }).and_call_original
elsif @provider == 'Google'
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything, { destination_predefined_acl: "publicRead" }).and_call_original
else
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything, {}).and_call_original
Expand Down

0 comments on commit 92a69de

Please sign in to comment.