Afternoon everyone!
I’ve been scratching my head over this one all morning. As always, a simple task has led me down the rabbit hole!
I’m trying to submit an image to the Kraken API for image processing (although if anyone has an alternative to image optimisation — I’m all ears!)
The following curl request does exactly what I need it to (I’ve omitted my API keys):
curl https://api.kraken.io/v1/upload -X POST --form data='{"auth": {"api_key": "API_KEY", "api_secret": "API_SECRET"}, "wait":true, "dev":true}' --form upload=@example.jpg
I’ve been trying to accomplish that from Elixir, using HTTPoison. Following all the troubleshooting issues/thread scattered around online, I think the closest I’ve got is this:
HTTPoison.post!("https://api.kraken.io/v1/upload", {:multipart, [{:upload, "~/example.jpg", { ["data"], [auth: [api_key: "\"API_KEY\"", api_secret: "\"API_SECRET\""], wait: "true", dev: "true"]}}]})
Perhaps this is just a syntax issue, as hackney puts out a variety of errors depending on how I tweak things, but the general gist is that it either can’t map over a :list
or that there’s not a function clause that matches. Is there anything blindingly obviously wrong with what I’ve written. I’m still quite “green” with Elixir, and I’ve ended up elbow deep in Erlang syntax, so could be missing something simple.
Alternatively, does anyone have a good solution to optimising images (and creating various sizes) before placing them all on S3. I’ve previously put a master image in storage and processed alterations on the fly with services like Imgix, but want to move away from that because of the expense mainly.
Any help would be greatly appreciated!
Cheers, Jamie.