is there any tutorial how to upload local files with HTTPoison.post ? opening a file
{:ok, file} = File.open "README.md"
HTTPoison.post("#{url}", file, headers)
this is for dropbox integration using upload functionality
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer " \
--header "Dropbox-API-Arg: {\"path\":\"/Homework/math/Matrices.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @local_file.txt
the problem is how to send —data-binary file.
Any ideas?
Thanks
I believe the equivalent of curl's --data-binary would be to use {:file, path} as the body, as documented in Hackney's README.md.
This should send the same request as your curl example:
HTTPoison.post("https://content.dropboxapi.com/2/files/upload",
{:file, "local_file.txt"},
[{"Authorization", "Bearer "}, ...])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With