Guest User

Untitled

a guest
Mar 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. class LocalFile
  2. # The filename, *not* including the path, of the "uploaded" file
  3. attr_reader :original_filename
  4. # The content type of the "uploaded" file
  5. attr_reader :content_type
  6.  
  7. def initialize(picture)
  8. content_type = picture.content_type
  9. path = picture.full_path
  10. raise "#{path} file does not exist" unless File.exist?(path)
  11. # content_type ||= @@image_mime_types[mine]
  12. raise "Unrecognized MIME type for #{path}" unless content_type
  13. @content_type = content_type
  14. @original_filename = File.basename(path)
  15. @tempfile = Tempfile.new(@original_filename)
  16. FileUtils.copy_file(path, @tempfile.path)
  17. end
  18.  
  19. def path #:nodoc:
  20. @tempfile.path
  21. end
  22. alias local_path path
  23.  
  24. def method_missing(method_name, *args, &block) #:nodoc:
  25. @tempfile.send(method_name, *args, &block)
  26. end
  27. end
Add Comment
Please, Sign In to add comment