diff --git a/lib/paperclip/storage/fog.rb b/lib/paperclip/storage/fog.rb index 8d0ed16a0..34650e490 100644 --- a/lib/paperclip/storage/fog.rb +++ b/lib/paperclip/storage/fog.rb @@ -114,6 +114,7 @@ def flush_writes raise if retried retried = true directory.save + file.rewind retry ensure file.rewind diff --git a/spec/paperclip/storage/fog_spec.rb b/spec/paperclip/storage/fog_spec.rb index a48db202e..e0c1d027a 100644 --- a/spec/paperclip/storage/fog_spec.rb +++ b/spec/paperclip/storage/fog_spec.rb @@ -199,6 +199,11 @@ def custom_method assert @dummy.save assert @connection.directories.get(@fog_directory) end + + it "sucessfully rewinds the file during bucket creation" do + assert @dummy.save + expect(Paperclip.io_adapters.for(@dummy.avatar).read.length).to be > 0 + end end context "with a bucket" do