I also made an example of this in a recent Akka HTTP showcase I toyed with. Client-side Scala.JS to upload is here <https://github.com/cretz/scala-web-ideal/blob/1f45cb3d71f0f0690b6b551a8d1de16f45263c57/client/src/main/scala/webideal/upload/UploadJsImpl.scala#L134>and server-side Akka HTTP is here <https://github.com/cretz/scala-web-ideal/blob/master/server/src/main/scala/webideal/upload/UploadPage.scala#L23> .
On Tuesday, June 16, 2015 at 1:33:46 AM UTC-5, Martynas Mickevičius wrote: > > Hi Maatary, > > you should use a marshaller to marshall MultiPart.Formdata to a > HttpRequest. Here > <https://github.com/2m/akka-stream-sandbox/blob/c8551eeb5ab6922f51b2114c9efe58b72525844e/src/test/scala/FileUploadSpec.scala> > > is an example of a file upload using client from akka-http. > > On Fri, Jun 5, 2015 at 6:31 PM, Maatary Okouya <maatar...@gmail.com > <javascript:>> wrote: > >> Hi, >> >> I'm trying to form a multi-part form data but can't figure out how, so >> far is what i wrote: >> >> >> object FileUploadSpike2 extends App { >> >> >> implicit val system = ActorSystem() >> implicit val materializer = ActorFlowMaterializer() >> >> import system.dispatcher >> >> val authorization = headers.Authorization(BasicHttpCredentials("xxxxxx", >> "xxxxxxx")) >> >> //val file = IOUtils.toByteArray(new FileInputStream(new File(""))); >> val path = Paths.get("/UNWOMEN_surveyreport_ADVANCE_16Oct-short.pdf"); >> val data = Files.readAllBytes(path); >> >> val payload = >> Multipart.FormData.apply(Multipart.FormData.BodyPart.Strict.apply("file", >> Strict.apply(ContentTypes.`application/octet-stream`, >> akka.util.CompactByteString.fromArray(data, 0, data.length)))) >> >> val responseFuture: Future[HttpResponse] = >> Http().singleRequest(HttpRequest(uri = "http://xxxxxxx"), entity= ??) >> >> responseFuture.foreach(e => println("result: " + e.entity.toString)) >> >> } >> >> -- >> >>>>>>>>>> Read the docs: http://akka.io/docs/ >> >>>>>>>>>> Check the FAQ: >> http://doc.akka.io/docs/akka/current/additional/faq.html >> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user >> --- >> You received this message because you are subscribed to the Google Groups >> "Akka User List" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to akka-user+...@googlegroups.com <javascript:>. >> To post to this group, send email to akka...@googlegroups.com >> <javascript:>. >> Visit this group at http://groups.google.com/group/akka-user. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Martynas Mickevičius > Typesafe <http://typesafe.com/> – Reactive > <http://www.reactivemanifesto.org/> Apps on the JVM > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.