Reputation: 8189
I'm making a multipart upload. Its request headers look like:
Accept:application/json,text/javascript
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.9
Connection:keep-alive
Content-Length:733
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary9Am5omyM263xjTB2
Host:localhost:4200
Origin:http://localhost:4200
Referer:http://localhost:4200/users/asdf/profile
User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1
I'm getting 415 Unsupported Media Type
as a response. However, I believe Phoenix is configured to accept multipart requests. In my config:
config :mime, :types, %{
"application/vnd.api+json" => ["json-api"],
"multipart/form-data" => ["multipart"]
}
And in my router:
plug :accepts, ["json", "json-api", "multipart"]
Any idea what's going on? I wonder if it has to do with the Accept-Enconding
?
Upvotes: 0
Views: 738
Reputation: 8189
Turns out the problem was that I was piping the request through ja_serializer. In particular, due to this line. Obviously, this wasn’t a json:api request, so it shouldn’t have been piped through there anyway.
Upvotes: 1
Reputation: 7146
After you configure the mime project in your config/config.exs (xml for example):
config :mime, :types, %{
"application/xml" => ["xml"]
}
And then run mix deps.clean --build mime
to force mime to be recompiled across all environments. You should be good to go now.
You can check if it's being recognized as a mime type I.E:
iex -S mix
iex> MIME.extensions("application/xml")
Upvotes: 0