Downloading files to perform upload action in a Pack

I’m trying to create an action on a Pack that grabs a file from a publicly accessible URL, get it’s content as base64 data and passes it on a API call to upload it to a certain entity on a third party service.

I’ve looked into the private images section on the documentation and a thread where @Eric_Koleda discusses it, tryied to buffer the data, but seems that extract data from a given URL is not an option.

Also I’m starting to think that if I have to fetch that data I’ll have problem with the domains (because those files are not in the same domain of the API I’m calling).

Is this “download file as base64” action possible in the pack studio environment?
If not in the pack studio, is this possible in the CLI environment?
Can I get a file data without performing a fetch against it?

Any help would be appreciated.

1 Like

Hi @hugo_assuncao - Downloading file content does use the fetcher, and so you must declare the network domain where the files are hosted. If the files are hosted on a consistent domain then you can ask for an exemption to allow your Pack to use multiple domains, but if the URL could be from any domain then there isn’t a solution within the Packs SDK itself.

One workaround would be to add the files to a Coda table File column first, and then use those files in the Pack. Packs can fetch data from without requesting an additional domain.

1 Like

Right now I’m getting them all from Google Drive - so a consistent URL – but I could use the Google Drive Extra pack, from @Rickard_Abraham, to get those external files into a Coda column and avoid the need to ask for an exemption (I already submitted a request to use custom authentication).

So, in order to get the file’s data I would just perform a fetch against it’s URL and… that’s it? Should I buffer it somehow or just get the result of the fetch request?

Yep, just fetch the file. The fetcher doesn’t support buffering of the content (although confusingly the JavaScript object that we return the data in is called Buffer). It does mean that you are limited to files 4MB or less, since that’s the cap we have for the fetcher.

Uhhh… that filesize limitation could be an issue… this pack was intended to get images of dental exams from Google Drive and upload to a dental clinic software.
Maybe is just simpler to use another tool, like Make, to do that part of the job.

Anyway, thanks for the quick and kind response @Eric_Koleda!

1 Like

Packs are woefully limited. The only reasonable approach is to build an independent service (like in Replit) that performs the collection orchestration and updates target Coda documents via the Coda AI or Coda webhooks.

If your data is already being collected in Google Drive, Google Apps Script can fulfill the orchestration requirements as the Coda API/Google Apps Script SDK is pretty awesome and easy to use.

Google Apps Script with this library makes it easy to fabricate more than a Pack can do.

1 Like