lib/attached/attachment.rb in attached-0.4.8 vs lib/attached/attachment.rb in attached-0.4.9
- old
+ new
@@ -155,17 +155,20 @@
def assign(file, identifier = Identifier.generate)
self.file = file
if file
- extension ||= file.extension if file.respond_to?(:extension)
- extension ||= File.extname(file.original_filename) if file.respond_to?(:original_filename)
- extension ||= File.extname(file.path) if file.respond_to?(:path)
+ extension ||= file.extension if file.respond_to? :extension
+ extension ||= File.extname(file.original_filename) if file.respond_to? :original_filename
+ extension ||= File.extname(file.path) if file.respond_to? :path
+
+ size ||= file.size if file.respond_to? :size
+ size ||= File.size(file.path) if file.respond_to? :path
end
@purge = [self.path, *self.styles.map { |style, options| self.path(style) }] if attached?
- self.size = file ? file.size : nil
+ self.size = file ? size : nil
self.extension = file ? extension : nil
self.identifier = file ? identifier : nil
process if file
end
\ No newline at end of file