From 6ba9c15d65c995dcfce92abcdcfdbaabe0fdf1d2 Mon Sep 17 00:00:00 2001 From: Nastia Gorokhova-Alekseeva Date: Mon, 12 Dec 2022 14:14:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B5=D0=BB=D0=B0=D0=B5=D0=BC=20rewind?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=D0=BC=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/paperclip/attachment.rb | 4 +++- lib/paperclip/storage/no_cache_s3.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/paperclip/attachment.rb b/lib/paperclip/attachment.rb index dc5a418..5c2233a 100644 --- a/lib/paperclip/attachment.rb +++ b/lib/paperclip/attachment.rb @@ -276,7 +276,9 @@ module Paperclip end def to_file(style = default_style) - queued_for_write[style] + file = queued_for_write[style] + file&.rewind + file end def to_io(*args) diff --git a/lib/paperclip/storage/no_cache_s3.rb b/lib/paperclip/storage/no_cache_s3.rb index 7ef960e..9fb56d3 100644 --- a/lib/paperclip/storage/no_cache_s3.rb +++ b/lib/paperclip/storage/no_cache_s3.rb @@ -234,6 +234,7 @@ module Paperclip }.merge(self.class.upload_options) files.each do |style, file| path = key(style) + file.rewind log "Saving to #{store_id}:#{path}" store.put_object(common_options.merge(key: path, body: file)) end