Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use file size of the io adapters #12

Closed
wants to merge 1 commit into from

2 participants

@stmichael

It makes sense to use the io adapters size method to determine the file size instead of using File.size(file). I got an error when I tried to assign a file object to the attachment property of my model.

TypeError:
       can't convert Paperclip::FileAdapter into String
     # /Users/ms/.rvm/gems/ruby-1.9.3-p0@equis-domain/gems/paperclip-meta-0.4.1/lib/paperclip-meta/attachment.rb:36:in `size'
     # /Users/ms/.rvm/gems/ruby-1.9.3-p0@equis-domain/gems/paperclip-meta-0.4.1/lib/paperclip-meta/attachment.rb:36:in `block in post_process_styles_with_meta_data'
     # /Users/ms/.rvm/gems/ruby-1.9.3-p0@equis-domain/gems/paperclip-meta-0.4.1/lib/paperclip-meta/attachment.rb:33:in `each'
     # /Users/ms/.rvm/gems/ruby-1.9.3-p0@equis-domain/gems/paperclip-meta-0.4.1/lib/paperclip-meta/attachment.rb:33:in `post_process_styles_with_meta_data'
     # /Users/ms/.rvm/gems/ruby-1.9.3-p0@equis-domain/gems/paperclip-3.0.1/lib/paperclip/attachment.rb:376:in `block (2 levels) in post_process'

I think this only occurs since paperclip version 3.0.0 since there were no io adapters before that.

@teeparham
Owner

This should be resolved. Closing as stale.

@teeparham teeparham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2012
  1. use file size of the io adapters

    Michael Stämpfli authored
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/paperclip-meta/attachment.rb
View
4 lib/paperclip-meta/attachment.rb
@@ -33,7 +33,7 @@ def post_process_styles_with_meta_data(*style_args)
@queued_for_write.each do |style, file|
begin
geo = Geometry.from_file file
- meta[style] = {:width => geo.width.to_i, :height => geo.height.to_i, :size => File.size(file) }
+ meta[style] = {:width => geo.width.to_i, :height => geo.height.to_i, :size => file.size }
rescue NotIdentifiedByImageMagickError => e
meta[style] = {}
end
@@ -88,4 +88,4 @@ def meta_decode(meta)
end
end
end
-end
+end
Something went wrong with that request. Please try again.