kemal/src/kemal/file_upload.cr

26 lines
668 B
Crystal
Raw Normal View History

2017-02-13 19:57:58 +00:00
module Kemal
# :nodoc:
2017-02-13 19:57:58 +00:00
struct FileUpload
getter tmpfile : Tempfile
getter filename : String?
2017-02-13 19:57:58 +00:00
getter headers : HTTP::Headers
getter creation_time : Time?
getter modification_time : Time?
getter read_time : Time?
getter size : UInt64?
2017-02-11 13:33:42 +00:00
def initialize(upload)
@tmpfile = Tempfile.new(filename)
::File.open(@tmpfile.path, "w") do |file|
IO.copy(upload.body, file)
end
@filename = upload.filename
@headers = upload.headers
@creation_time = upload.creation_time
@modification_time = upload.modification_time
@read_time = upload.read_time
@size = upload.size
2017-02-13 19:57:58 +00:00
end
2017-02-11 13:33:42 +00:00
end
2017-02-13 19:57:58 +00:00
end