Image from HTTP GET request to Cloudinary - wrong workflow or does the image get corrupted?

Hi.

I am trying to get images from Akeneo to Cloudinary. It is possible to retrieve the file, but it is then not accepted by Cloudinary.

I tried a few different ways (e. g. with encoding the result to base64), but nothing worked. Direct input of the returned binary to the Cloudinary step lead to a time-out. Sidenote: should such a thing be possible or is it bad practice anyway?

Saving the image to tmp and using it from there to upload to Cloudinary gives the following error right now:

{"message":"Invalid image file","name":"Error","http_code":400}

But the saving to tmp worked alright. I could get it from there to encode it in another step to base64, which I also tried once if it changed anything. It didn’t.

When I save the binary I received in Pipedream to my Mac, the resulting file can’t be opened as an image. When I compare the binary to the original image, it looks different. I know nothing about encoding, but could this be an issue or is the file getting corrupted on the way?

Left is returned binary in Pipedream, right is the source image downloaded from Akeneo:

In Postman the file looks good and can be previewed:

(Btw: a preview option would be awesome for Pipedream)

Am I not having the full picture here or has the file handling indeed technical problems?

Thanks in advance,
Anton

Hello @anzglr,

I think there might be a problem with your code to save the base64 string as image to the /tmp dir. I think you can use a library like this instead?

Encoding the file to base64 was just one of different tries. One option was handing over the binary file and another was as base64 string.

Cloudinary accepts an image in the following formats:

And as I said, I tried to open the retrieved binary (no base64 encoding) and the file wasn’t working.

Hello @anzglr,

Base64 encoding string is a possible solution, as other user have tried and got it works. I’m not sure how Pipedream handles the the binary format

Hello @vunguyenhung,

The thing is that the binary is the source of the Base64 encoded string. So if the source file is already faulty, the Base64 won’t work as well. And to me it seems that way.

Could you maybe give me some insights to how exactly it has been used successfully by other users? Does that mean the Cloudinary connector?

Hello @anzglr,

I see. The successful case is the user uses base64 to save to file. Not specifically for Cloudinary

What happen when you reference the image binary data to Cloudinary’s File prop?
So it would be something like File: {{ steps.akeneo_get_asset_file.$return_value }}

Hi @vunguyenhung ,

then I get this error:

The argument 'path' must be a string or Uint8Array without null bytes. Received '����\x00\x10JFIF\x00\x01\x01\x01\x01,\x01,\x00\x00��\x00\x18Exif\x00\x00II*\x00\b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00��...


Hi @vunguyenhung.

Should it work that way? Direct input of the binary data to the file property on the Cloudinary app, I mean?

That is how I would expect it to work.

But as I said, the binary I get as a result in the previous step, already doesn’t look right to me. Or how else can that difference be explained?

Hi @anzglr,

Then I think your previous step might be a problem. Could you check the API Doc from akeneo to see how to handle their response? Maybe you need to change the Content-Type or Accept header? Or maybe you might need to use Pipedream code action instead of the HTTP action to do some customization of the response?

Hi @vunguyenhung .

The thing is that it is already as described in the documentation and there is not a lot to take care of anyway:

Also in Postman it’s working.

I tried multiple images and it’s always the same:
Image in Postman is alright and in Pipedream it’s broken.

@anzglr,

Pipedream has a built in action Download file to tmp dir, would you mind give it a try to download the image?

@vunguyenhung ,

sure. I tried, but it seems that it only accepts URLs as input.

Hi @anzglr,

I mean you can put the akeneo url to download the image there

@vunguyenhung

There is no public URL. Images have to be requested by the API. Or what URL do you mean?

Hi @anzglr,

Could you try to put the URL of the Akeneo API?

I think this support is more on the usecase side. So if you have the Team plan, you’ll be invited to a dedicated support channel. Or if you’d like to hire a Pipedream expert for your usecase, feel free to use this link: Connect with a Pipedream Partner

Hi @vunguyenhung,

If I am just putting in the URL of the API in this type of step, the authentification part is missing. So there won’t be a result.

No, I don’t have a team plan. I am just trying use cases we could present to our (potential) customers. But I heard that Akeneo (I work there) is thinking about a partnership with Pipedream. So maybe I have to wait until this is settled and we have a base to discuss this properly. :slight_smile:

Thanks for your time and effort!

1 Like