Hi Guys, im trying to upload a file to Dropbox. I have a view that accepts the file and I can access that file through the params. But I can’t seem to create the right http post request to dropbox using HTTPoison… Could you help out a newbie? Am I doing it right? Is there a better way? Much appreciated.
def create(conn, %{"file" => file} = params) do
url = "https://content.dropboxapi.com/2/files/upload"
token = "MYTOKEN"
header = [
{"Authorization", "Bearer #{token}"},
{"Dropbox-API-Arg", "{\"path\": \"/dropboxtest/jeff.png\"}"},
{"Content-Type: application/octet-stream"}
]
body = File.read(file[:path])
IO.inspect(HTTPoison.post(url, body, header))
end