I solved it. For those who are interested in, here is the solution:
defp upload_static_file(%{path: path}, socket) do
IO.inspect("EMERAT")
dest = Path.join("priv/static/images", Path.basename(path))
# File.cp!(path, dest)
{_, content } = File.read(path)
b64 = Base.encode64(content)
IO.inspect(b64)
request1 = %HTTPoison.Request{
method: :post,
url: "https://api.imgbb.com/1/upload",
options: [],
headers: [],
params: [
{~s|expiration|, ~s|600|},
{~s|key|, ~s|SECRET|},
],
body: {:multipart, [
{~s|image|, ~s|#{b64}|}
]}
}
response = HTTPoison.request(request1)
IO.inspect("This is what we get")
IO.inspect(response)
# Routes.static_path(socket, "/images/#{Path.basename(dest)}")
end