Hi Nykolas,

you need to use unmarshalling to negotiate the content type of the request.
Take a look at the example here
<https://github.com/2m/akka-stream-sandbox/blob/d1abb6fefd7bebc674f847a24c4a00151c5345a5/src/main/scala/HttpFlow.scala#L41>
.

On Mon, Jun 15, 2015 at 11:42 PM, Nykolas de Lima <[email protected]>
wrote:

> Hello guys,
> I'm trying to make a file upload with Akka Http, but I'm getting an error
> about Unsupported Media Type, requiring me to send application/json. But
> it's a file upload, so my content-type is multipart/form-data.
> Where can I configure Akka Http to support this
> content-type(multipart/form-data)?
>
> Here is my code:
>
> (post & path("photos")) {
>   extractRequest { request =>
>     request.entity.dataBytes.via(photoUpload).to(Sink.ignore).run()
>     complete(OK)
>   }
> }
>
>
> val photoUpload =
>   Flow[ByteString]
>     .map(file => {
>       val bucket = s3.bucket("test")
>       val metadata: ObjectMetadata = new ObjectMetadata()
>       metadata.setContentLength(file.toArray.length)
>       bucket.get.putObject("testImage", file.toArray, metadata)
>     })
>
>  --
> >>>>>>>>>> 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 [email protected].
> To post to this group, send email to [email protected].
> 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 [email protected].
To post to this group, send email to [email protected].
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