daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Technoweenie::AttachmentFu::InstanceMethods.class_eval do
  2.   def uploaded_data=(file_data)
  3.     return nil if file_data.nil? || file_data.size == 0
  4.     self.size = file_data.size
  5.     self.content_type = file_data.content_type
  6.     self.filename     = file_data.original_filename if respond_to?(:filename)
  7.     if file_data.is_a?(StringIO)
  8.       file_data.rewind
  9.       self.temp_data = file_data.read
  10.     else
  11.       self.temp_path = file_data.path
  12.     end
  13.   end
  14.  
  15.   def set_size_from_temp_path
  16.     self.size = File.size(temp_path) if save_attachment? && (self.size == 0 || self.size.nil?)
  17.   end
  18.  
  19. end
RAW Paste Data
Top