Binary file from an API Call

Hi everyone,

I’m trying to get a binary file from an API (a PNG) that I want to send to Cloudinary. My problem is that I suspect that there is an encoding issue on Pipedream. I did the exact same Get request on Postman and the result is not the same (see pictures). Any idea?

here is the result with postman, on the same request

Hi @geoffreypasquier

First off, welcome to the Pipedream community. Happy to have you!

I believe you may need to convert it to base64 before sending it to Cloudinary’s API.

export default defineComponent({
  async run({ steps, $ }) {

    const buff = new Buffer(steps.custom_request_2.$return_value);
    const base64data = buff.toString('base64');

    return base64data;
  }
})

Hopefully this helps!

Hi @pierce

Thanks for your help!
In fact yes I need to convert it in base64 before sending this to Cloudinary’s API and I reused your code that was better than mine
But my issue here is in the interpretation of Pipedream (one step before converting to base 64). You can see the result of the same request to get the image from Akeneo API on my two screenshots (the first is from pipedream and the other from Postman.
I guess something is wrong with Pipedream encoding or something like that.

Hi @geoffreypasquier

Of course happy to help :slight_smile:

It could just be that your terminal outputs in unicode, but Pipedream’s outputs in ASCII. The symbols do look different.

Once you have your photo uploaded to Cloudinary, that will tell us if there is some kind of encoding problem. If there is some kind of corruption of the photo when it reaches Cloudinary and you try to view it, please let me know!

Infortunately it does not work…

Hi @geoffreypasquier

Is the file you’re trying to download a public URL?

If so could you share it and a screenshot of the Cloudinary action or code you’re trying to use to upload the file?

From there we could troubleshoot further!

have you ever figured this out? I need to do the same thing.