ijunaidfarooq
How to make a multipart HTTP request using finch
I have a file, such as junaid.jpeg.
I am reading it as data = File.read!("junaid.jpeg") and I want to send that data as multipart data request using finch.
this is what my whole module looks like
defmodule EvercamFinch do
def request(method, url, headers \\ [], body \\ nil, opts \\ []) do
transformed_headers = tranform_headers(headers)
request = Finch.build(method, url, transformed_headers, body)
case Finch.request(request, __MODULE__, opts) do
{:ok, %Finch.Response{} = response} ->
{:ok, response}
{:error, reason} ->
{:error, reason}
end
end
defp tranform_headers([]), do: []
defp tranform_headers(headers) do
headers
|> Enum.map(fn({k, v}) ->
{Atom.to_string(k), v}
end)
end
end
and when I send this data, I am getting this error.
iex(5)> EvercamFinch.request(:post, "http://localhost:8888/test/junaid.png", ["Content-Type": "multipart/form-data"], data, [receive_timeout: 15_000])
{:ok,
%Finch.Response{
body: "{\"error\":\"no multipart boundary param in Content-Type\"}",
headers: [
{"content-type", "application/json"},
{"server", "SeaweedFS Filer 30GB 2.05"},
{"date", "Mon, 14 Dec 2020 17:47:28 GMT"},
{"content-length", "55"},
{"connection", "close"}
],
status: 500
}}
I am confused about how I can make a multipart request using finch(mint), is it supported or not? or how to make it work?
Popular in Questions
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
In templates/appointment/index.html.eex:
<%= for appointment <- @appointments do %>
<tr>
<td><%= appoi...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Other popular topics
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
What learn first? Rust or Elixir
Hi Elixir community!
I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









