http://railsforum.com/viewtopic.php?id=6307
Code : - fold - unfold
and added conditionals for the size- def uploaded_data=(file_data)
- return nil if file_data.nil? || file_data.size == 0
- self.size = file_data.size
- self.content_type = file_data.content_type
- self.filename = file_data.original_filename if respond_to?(:filename)
- if file_data.is_a?(StringIO)
- file_data.rewind
- self.temp_data = file_data.read
- else
- self.temp_path = file_data.path
- end
- end
Code : - fold - unfold
- def set_size_from_temp_path
- self.size = File.size(temp_path) if save_attachment? && (self.size == 0 || self.size.nil?)
- end
on 10.04.2007 01:34
http://www.ruby-forum.com/topic/99870
To get things working with S3 and windows, I changed: def temp_data if save_attachment? f = File.new( temp_path ) f.binmode return f.read else return nil end end (before, the method body was save_attachment? ? File.read( temp_path ) : nil )
0 comments:
Post a Comment