require "kemal"
post "/upload" do |env|
parse_multipart(env) do |f|
file_path = File.join Dir.current, "image.png"
File.open(file_path, "w") do |file|
IO.copy(f.data, file)
end
"Upload complete"
end
end
Kemal.run
Exception: header content contains invalid character '\u{0}' (ArgumentError)
0x10a0936c2: *CallStack::unwind:Array(Pointer(Void)) at ??
0x10a093661: *CallStack#initialize:Array(Pointer(Void)) at ??
0x10a093638: *CallStack::new:CallStack at ??
0x10a090651: *raise<Exception+>:NoReturn at ??
0x10a09048d: ~procProc(HTTP::Server::Context, Nil)@src/app.cr:3 at ??
0x10a08f4db: ~procProc(HTTP::Server::Context, String)@lib/kemal/src/kemal/route.cr:11 at ??
0x10a15195b: *Kemal::RouteHandler#process_request<HTTP::Server::Context>:HTTP::Server::Context at ??
0x10a1518d9: *Kemal::RouteHandler#call<HTTP::Server::Context>:HTTP::Server::Context at ??
0x10a1666d8: *Kemal::StaticFileHandler@HTTP::Handler#call_next<HTTP::Server::Context>:(Array(IO) | Bool | HTTP::Server::Context | HTTP::Server::Response | HTTP::Server::Response::Output | IO::FileDescriptor+ | Int32 | Nil) at ??
0x10a1655fd: *Kemal::StaticFileHandler#call<HTTP::Server::Context>:(Array(IO) | Bool | HTTP::Server::Context | HTTP::Server::Response | HTTP::Server::Response::Output | IO::FileDescriptor+ | Int32 | Nil) at ??
0x10a164c4f: *Kemal::CommonExceptionHandler@HTTP::Handler#call_next<HTTP::Server::Context>:(Array(IO) | Bool | HTTP::Server::Context | HTTP::Server::Response | HTTP::Server::Response::Output | IO::FileDescriptor+ | Int32 | Nil) at ??
0x10a164790: *Kemal::CommonExceptionHandler#call<HTTP::Server::Context>:(Array(IO) | Bool | HTTP::Server::Context | HTTP::Server::Response | HTTP::Server::Response::Output | IO::FileDescriptor+ | Int32 | Nil) at ??
0x10a163d76: *Kemal::CommonLogHandler@HTTP::Handler#call_next<HTTP::Server::Context>:(Array(IO) | Bool | HTTP::Server::Context | HTTP::Server::Response | HTTP::Server::Response::Output | IO::FileDescriptor+ | Int32 | Nil) at ??
0x10a16188d: *Kemal::CommonLogHandler#call<HTTP::Server::Context>:HTTP::Server::Context at ??
0x10a15134e: *Kemal::InitHandler@HTTP::Handler#call_next<HTTP::Server::Context>:(Array(IO) | Bool | HTTP::Server::Context | HTTP::Server::Response | HTTP::Server::Response::Output | IO::FileDescriptor+ | Int32 | Nil) at ??
0x10a150f9a: *Kemal::InitHandler#call<HTTP::Server::Context>:(Array(IO) | Bool | HTTP::Server::Context | HTTP::Server::Response | HTTP::Server::Response::Output | IO::FileDescriptor+ | Int32 | Nil) at ??
0x10a16cd09: *HTTP::Server::RequestProcessor#process<(OpenSSL::SSL::Socket::Server | TCPSocket+), (OpenSSL::SSL::Socket::Server | TCPSocket+), IO::FileDescriptor>:Nil at ??
0x10a16c705: *HTTP::Server::RequestProcessor#process<(OpenSSL::SSL::Socket::Server | TCPSocket+), (OpenSSL::SSL::Socket::Server | TCPSocket+)>:Nil at ??
0x10a167476: *HTTP::Server#handle_client<(TCPSocket+ | Nil)>:Nil at ??
0x10a0917c6: ~procProc(Nil)@/usr/local/Cellar/crystal-lang/0.20.3/src/http/server.cr:148 at ??
0x10a09d654: *Fiber#run:(IO::FileDescriptor | Nil) at ??
0x10a08ce99: ~proc2Proc(Fiber, (IO::FileDescriptor | Nil))@/usr/local/Cellar/crystal-lang/0.20.3/src/fiber.cr:29 at ??
curl -F "image1=@/Users/serdar/Desktop/Screenshots/logo.png" http://localhost:3000/upload