Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

binmode and Tempfile fixes for windows

  • Loading branch information...
commit b48cea76ef527d159df9247b1f81c7fb0fa62dee 1 parent d92be0d
@jyurek jyurek authored
Showing with 16 additions and 0 deletions.
  1. +1 −0  lib/paperclip/attachment.rb
  2. +15 −0 lib/paperclip/iostream.rb
View
1  lib/paperclip/attachment.rb
@@ -67,6 +67,7 @@ def assign uploaded_file
return nil unless valid_assignment?(uploaded_file)
logger.info("[paperclip] Assigning #{uploaded_file.inspect} to #{name}")
+ uploaded_file.binmode if uploaded_file.respond_to? :binmode
queue_existing_for_delete
@errors = []
@validation_errors = nil
View
15 lib/paperclip/iostream.rb
@@ -41,3 +41,18 @@ class IO
end
end
end
+
+# Corrects a bug in Windows when asking for Tempfile size.
+if defined? Tempfile
+ class Tempfile
+ def size
+ if @tmpfile
+ @tmpfile.fsync
+ @tmpfile.flush
+ @tmpfile.stat.size
+ else
+ 0
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.