123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Http::UploadedFile

Relationships & Source Files
Inherits: Object
Defined in: actionpack/lib/action_dispatch/http/upload.rb

Overview

Action Dispatch HTTP UploadedFile

Models uploaded files.

The actual file is accessible via the #tempfile accessor, though some of its interface is available directly for convenience.

Uploaded files are temporary files whose lifespan is one request. When the object is finalized Ruby unlinks the file, so there is no need to clean them with a separate maintenance task.

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#content_type (rw)

A string with the MIME type of the file.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 20

attr_accessor :content_type

#eof?Boolean (readonly)

Shortcut for tempfile.eof?.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 96

def eof?
  @tempfile.eof?
end

#headers (rw)

A string with the headers of the multipart request.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 27

attr_accessor :headers

#original_filename (rw)

The basename of the file in the client.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 17

attr_accessor :original_filename

#tempfile (rw)

A Tempfile object with the actual uploaded file. Note that some of its interface is available directly.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 24

attr_accessor :tempfile

Instance Method Details

#close(unlink_now = false)

Shortcut for tempfile.close.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 71

def close(unlink_now = false)
  @tempfile.close(unlink_now)
end

#open

Shortcut for tempfile.open.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 66

def open
  @tempfile.open
end

#path

Shortcut for tempfile.path.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 76

def path
  @tempfile.path
end

#read(length = nil, buffer = nil)

Shortcut for tempfile.read.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 61

def read(length = nil, buffer = nil)
  @tempfile.read(length, buffer)
end

#rewind

Shortcut for tempfile.rewind.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 86

def rewind
  @tempfile.rewind
end

#size

Shortcut for tempfile.size.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 91

def size
  @tempfile.size
end

#to_io

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 100

def to_io
  @tempfile.to_io
end

#to_path

Shortcut for tempfile.to_path.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/upload.rb', line 81

def to_path
  @tempfile.to_path
end