Binary files: Download and Upload through HTTP Request

A little background on use-case…

For those who joyously use Trello, you know that graphics attached in cards recently got a security makeover - meaning those graphics can no longer be referenced or linked to publicly. It requires any viewer to have specific member access to that content within Trello. Ugh.

We need to pull the graphic (attachment) from the card in Trello and upload it to GDrive (or other cloud storage) for public distribution, in our case by email. As a migrant from Integromat/Make, I reminisce over the ease of use with this option:

I need to do essentially the same thing in n8n now. Will this require a third (intermediary) step, using the Write Binary File node? Or can I simply grab the binary from the Trello request, and pass it to GDrive?

Does someone have a guide/video/tutorial for this? I’m a bit out of my element and unable to get this working. I think I’m doing several things wrong here. My end result is a PNG file with binary text inside, saved into my main G Drive directory (not the intended folder).

Here’s the workflow:

Can anyone point me in the right direction here?

Thanks!

EP

Hi @Entrepositive, downloading a binary file and then storing it on Google Drive wouldn’t require an additional node.

I suspect your Trello HTTP request might not return what you expect it to return. Check this example for downloading an image and then storing it on Google Drive:

Can you check the file coming from Trello is the file you are expecting? You can view it like so (or alternatively download it if there is no built-in viewer for it):

Hey @MutedJam

Thanks for your response. I was able to successfully run your model, with no auth, using your own image link you used. However, when I replaced the URL with my own (Trello) image link, it did not work.

I tried using my Trello auth, which has access to the graphic, but that did not work either.

In both cases, the binary summary populates correctly, and the “View” button functions but no graphic is displayed. I tend to suspect this is an authorization issue with Trello, unless it seems I’m clearly executing this incorrectly.

EP

Hey @Entrepositive,

It does sound like it could be a credential issue, If you enable the full response option does it show anything else?

Hi @Jon

I just tried that and got same result as before…

What confuses me here is that even with the Trello credentials, I have the same problem.

I would expect it either:

  • worked with the right credentials or
  • failed with an authorization issue without the credentials…

Hey @Entrepositive,

I would have expected it to work as well, When you use the full response do you see anything in the output table like the headers?

Yes I do in Table view:

**headers**
{
 [Now removed]
}

And here’s the Trello doc on Card Attachments. Pretty limited but I wouldn’t suspect we’d need much more from Trello…
https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-idattachment-get

I recall there was a big drama when Trello made the attachments private. Make/integromat scrambled to come up with the “Download Attachment” node for the Trello connection.

To venture a guess, perhaps that integromat function is handling more than one step… I think it handled the authorization, pulling the graphic data (I guess that’s the “binary”?) and it made it an object within the workflow.

I’m open to ideas… :sweat_smile:

Let me know if the headers contain sensitive info that I should remove… I’m a noob but I’m not looking to get hacked by some ahole haha

Was there anything else in that response? There is a content-length which is interesting but the content-type is txt/html not an image.

Can you set the response to json? I think looking at the API docs you will need 2 nodes and this first one will return a download URL you can use.

The response just passed 200 status code. Otherwise empty response…
image

It appears to give same response also when I toggle the “JSON/RAW Parameters” switch ON.

Is there any way to crack this open and see what Integromat is doing here? Wondering if it’s possible to reverse engineer this…

I have a feeling this is a critical piece. I’ll check back in here after a little digging:

…specifically this part:

Making a GET request with the key and token will return a 302 that redirects to the URL of the hosted file. You will always be 302’ed so long as the tokened user has access to the attachment. The route you are redirected to is only valid for 1 hour.

Looking at the API docs when you call https://trello.com/1/cards/nekAAA7H/attachments/62f6c50fe4ba56837b626d57 it should return something like…

{
  "id": "5abbe4b7ddc1b351ef961414",
  "bytes": "<string>",
  "date": "2018-10-17T19:10:14.808Z",
  "edgeColor": "yellow",
  "idMember": "5abbe4b7ddc1b351ef961414",
  "isUpload": false,
  "mimeType": "",
  "name": "Deprecation Extension Notice",
  "previews": [],
  "url": "https://admin.typeform.com/form/RzExEM/share#/link",
  "pos": 1638
}

Ah you’re right - my bad @Jon .

I am using a different URL format now, but forgot to mention earlier, from this comment onward. With the URL format you mentioned, I would get such a response. Interestingly enough, with the below URL format, I still get txt/html content-type.

I’m using this URL format:
https://api.trello.com/1/cards/{id}/attachments/{idAttachment}?key=APIKey&token=APIToken
and presumably, n8n is loading the API key and token automatically, when I set up the auth creds. Could that be a bad assumption?

Hey @Entrepositive,

It will be if you don’t add the ?key= part otherwise it will add it again. So if you use https://api.trello.com/1/cards/nekAAA7H/attachments/62f6c50fe4ba56837b626d57 what do you get back in the full response json?

If I run that, I get a application/json content type in a 200 response, with different headers than discussed before. Binary dialog:
image

Further, I tried following this article, with the “newer” URL format that includes “/download/” and got the below binary output. It seems I have 1 hour to access the graphic, and push it to Drive/cloud, otherwise it’s no longer accessible.
image

But even so I still can’t view the graphic from the binary dialog box, as I could with your public image link from before.

If you download that image are you able to view it? It could just be something odd with the viewer.

Good thought. It won’t open but has +200kb. It’s a corrupted img file…

Sounds like I might need to set up a Trello account in the morning to test :slightly_smiling_face:

:sweat_smile: here’s a link to the public board I set up