class
Kemal::FileUpload
- Kemal::FileUpload
- Reference
- Object
Overview
A file part of a multipart/form-data request, spooled to a temporary file
that is removed when the request is over.
Read it with #open, or hand #path to whatever stores it:
upload = env.params.files["image"]
upload.open { |file| IO.copy(file, destination) }
File.copy(upload.path, "public/uploads/#{upload.filename}")
Defined in:
kemal/file_upload.crConstructors
Instance Method Summary
- #cleanup
- #creation_time : Time | Nil
- #filename : String | Nil
- #headers : HTTP::Headers
- #modification_time : Time | Nil
-
#open(& : File -> T) : T forall T
Opens the upload for reading, yields the file and closes it.
-
#path : String
Path of the temporary file holding the upload.
- #read_time : Time | Nil
-
#size : UInt64 | Nil
Bytes written to disk - not what the part's
Content-Dispositionclaimed. -
#tempfile : File
The upload as an open
File, positioned at its start, kept open until the request is over.DEPRECATED Use
open(&)to read the upload or#pathto move it
Constructor Detail
Instance Method Detail
The upload as an open File, positioned at its start, kept open until the
request is over. A handle per upload is what the default ulimit runs out
of a few concurrent requests in; #open closes when it is done, and #path
needs no handle at all.
DEPRECATED Use open(&) to read the upload or #path to move it