Class: Rack::LargeUploads::UploadedFile
- Inherits:
-
ActionDispatch::Http::UploadedFile
- Object
- ActionDispatch::Http::UploadedFile
- Rack::LargeUploads::UploadedFile
- Defined in:
- lib/rack/large-uploads/uploaded_file.rb
Instance Method Summary collapse
- #clean!(nilify = true) ⇒ Object
-
#initialize(hash) ⇒ UploadedFile
constructor
A new instance of UploadedFile.
- #present? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ UploadedFile
Returns a new instance of UploadedFile.
4 5 6 7 8 9 10 11 12 |
# File 'lib/rack/large-uploads/uploaded_file.rb', line 4 def initialize(hash) tempfile = hash[:tempfile] hash[:tempfile] = ::File.new(tempfile) if tempfile.is_a?(String) @uploaded_md5 = hash.delete(:md5) @uploaded_size = hash.delete(:size) super(hash) @uploaded_path = path end |
Instance Method Details
#clean!(nilify = true) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rack/large-uploads/uploaded_file.rb', line 14 def clean!(nilify = true) raise "No such file or directory - #{@uploaded_path}" unless present? ::File.delete(@tempfile.path) # NOTE: it appears that an open file descriptor (or similar) remains # after the file is removed on the filesystem. in most cases, we # should expect to be unable to interact with the file after cleaning, # but we make it optionally allowed. if nilify @tempfile = nil end self end |
#present? ⇒ Boolean
29 30 31 |
# File 'lib/rack/large-uploads/uploaded_file.rb', line 29 def present? @tempfile != nil end |