diff --git a/lib/paperclip/storage/s3.rb b/lib/paperclip/storage/s3.rb index b387edc21..eec2f74fc 100644 --- a/lib/paperclip/storage/s3.rb +++ b/lib/paperclip/storage/s3.rb @@ -412,11 +412,7 @@ def flush_deletes #:nodoc: def copy_to_local_file(style, local_dest_path) log("copying #{path(style)} to local file #{local_dest_path}") - ::File.open(local_dest_path, 'wb') do |local_file| - s3_object(style).get do |chunk| - local_file.write(chunk) - end - end + s3_object(style).download_file(local_dest_path) rescue Aws::Errors::ServiceError => e warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}") false