Guest User

Untitled

a guest
May 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. module Paperclip
  2. class Attachment
  3.  
  4. class UploadedPath
  5. attr_reader :original_filename, :content_type, :size, :path
  6. def initialize(uploaded_file)
  7. @original_filename = uploaded_file["name"].downcase
  8. @content_type = uploaded_file["content_type"].to_s.strip
  9. @size = uploaded_file["size"].to_i
  10. @path = uploaded_file["path"]
  11. `#{Rails.root}/script/chmod #{@path}`
  12. end
  13.  
  14. def to_tempfile
  15. self
  16. end
  17.  
  18. def close
  19. end
  20. end
  21.  
  22. def assign_with_upload(uploaded_file)
  23. uploaded_file = UploadedPath.new(uploaded_file) if uploaded_file.is_a?(Hash)
  24. assign_without_upload(uploaded_file)
  25. end
  26. alias_method_chain :assign, :upload
  27. end
  28. end
Add Comment
Please, Sign In to add comment