Skip to content

Commit

Permalink
The method #uploader_options feels generic, renaming to more specific…
Browse files Browse the repository at this point in the history
… one
  • Loading branch information
mshibuya committed Feb 13, 2021
1 parent 459dfbe commit 6682f7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/carrierwave/storage/fog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def filename(options = {})
# @return [CarrierWave::Storage::Fog::File] the location where the file will be stored.
#
def copy_to(new_path)
connection.copy_object(@uploader.fog_directory, file.key, @uploader.fog_directory, new_path, uploader_options)
connection.copy_object(@uploader.fog_directory, file.key, @uploader.fog_directory, new_path, copy_options)
CarrierWave::Storage::Fog::File.new(@uploader, @base, new_path)
end

Expand Down Expand Up @@ -494,7 +494,7 @@ def file
@file ||= directory.files.head(path)
end

def uploader_options
def copy_options
options = {}
options.merge!(acl_header) if acl_header.present?
options['Content-Type'] ||= content_type if content_type
Expand Down
5 changes: 4 additions & 1 deletion spec/storage/fog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def check_file
end
end

context '#uploader_options' do
context '#copy_options' do
let(:store_path) { 'uploads/test+.jpg' }
let(:fog_attributes) { { 'x-amz-server-side-encryption' => true } }

Expand All @@ -75,6 +75,9 @@ def check_file
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything,
{ "Content-Type"=>file.content_type, "x-amz-acl"=>"public-read", 'x-amz-server-side-encryption' => true }).and_call_original
elsif @provider == 'Google'
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything, { "Content-Type"=>file.content_type, destination_predefined_acl: "publicRead" }).and_call_original
else
expect(@storage.connection).to receive(:copy_object)
.with(anything, anything, anything, anything, { "Content-Type"=>file.content_type }).and_call_original
Expand Down

0 comments on commit 6682f7a

Please sign in to comment.