akka / akka-http

The Streaming-first HTTP server/module of Akka
https://doc.akka.io/docs/akka-http
Other
1.34k stars 594 forks source link

POST for uploading files not via `MultiPart.FormData` #141

Open akka-ci opened 7 years ago

akka-ci commented 7 years ago

Issue by hhimanshu Friday Dec 04, 2015 at 23:57 GMT Originally opened as https://github.com/akka/akka/issues/19093


As discussed in https://github.com/akka/akka/issues/19092, it would be nice to have a directive that can be used to upload files.

Opened ticket as discussed with @ktoso

akka-ci commented 7 years ago

Comment by ktoso Friday Dec 04, 2015 at 23:58 GMT


More specifically, it's about taking in a request like curl -X POST -d@dat_data.txt (i.e. not FormData, just raw data in the request body (as seen in dataBytes).

akka-ci commented 7 years ago

Comment by ktoso Friday Dec 04, 2015 at 23:58 GMT


Thanks for opening the ticket!

akka-ci commented 7 years ago

Comment by hhimanshu Saturday Dec 05, 2015 at 00:02 GMT


+1

akka-ci commented 7 years ago

Comment by 2beaucoup Monday Dec 07, 2015 at 09:26 GMT


Having thought abou this once again I'm not sure anymore if we should provide such directives (even the existing fileUpload/uploadedFile) by default.

"File uploading" could happen in many different ways: Uploading via multipart or plain (POST, PUT) requests, storing as a temp file, direct storage or streaming to consumers. I'm sure there are more.

Trying to provide a directive for every combination doesn't scale. I think we could give better support for extracting things from multipart/formdata entities and provide some samples re. file storage as cookbook recipes. We should rather get the building blocks right than trying to provide a directive for every use case.

@hhimanshu What kind of problems did you come across when implementing your uploads? Was it just getting the curl stuff right or with implementing the service itself?

/cc @sirthias

akka-ci commented 7 years ago

Comment by johanandren Monday Dec 07, 2015 at 09:57 GMT


There just was a discussion like this in #19108

It's a hard balance between the API being easy to pick up and bloated with special use cases.

akka-ci commented 7 years ago

Comment by johanandren Monday Dec 07, 2015 at 09:59 GMT


I think we could just provide some documentation about POSTing files here: http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-M2/scala/http/routing-dsl/index.html#File_uploads

akka-ci commented 7 years ago

Comment by ktoso Thursday May 19, 2016 at 00:52 GMT


I think this is solved, isn't it @johanandren ?

akka-ci commented 7 years ago

Comment by johanandren Thursday May 19, 2016 at 06:41 GMT


Well, not really, no docs added and no directive for it. (http://doc.akka.io/docs/akka/2.4.5/scala/http/routing-dsl/index.html#File_uploads)

akka-ci commented 7 years ago

Comment by ktoso Thursday May 19, 2016 at 20:40 GMT


I see, reopening thanks

akka-ci commented 7 years ago

Comment by 2beaucoup Tuesday Sep 06, 2016 at 12:46 GMT


This should just be a

extractDataBytes(_.runWith(FileIO.toFile(file)))

Do we need special docs for that?