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 <maatarioko...@gmail.com>
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+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.
>



-- 
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.

Reply via email to