I’ve set up an S3 bucket and can upload/download files in my N8N workflow.
What I need now is to generate a secure, time-limited download URL for the file, rather than downloading it directly.
The goal is to send this URL to Budibase, where it will be linked to a download button.
I guess what I need to do is generate a pre-signed, expiring download URL but despite seeing the threads about that, I can’t find or do a working workflow.
My “read” request in budibase gives me this (anonymized):
It would be handy to pop a vote on that feature request, To generate the link we don’t have an example for that at the moment so it would be a case of following the Amazon documentation on how to make the signature which could be tricky.
If I get a chance I will take a look and see if I can work out a quick script to do it if the example in the other post isn’t working.
Are you also AWS S3 or an S3 compatibale storage option?
I was also wondering about that. the closest solution I came up with is installing S3 CLI utility, attaching it to you S3 bucket and then calling Execute Command node from n8n.
It uses the @aws-sdk/client-s3 which is available to n8n. See docs here.
However this version of @aws-sdk doesn’t come with the @aws-sdk/s3-request-presigner which is required for signing urls. See docs here.
We can hack around this by installing this library via npm using the execute command.
You can require libraries via absolute paths so that’s how we bring it in to the code node.
Good to know
require('@aws-sdk') in code node doesn’t work because n8n doesn’t come with the “full fat” AWS package. It may have in the past but I think this was changed at some point.
Solution of @Jim_Le is really helpful and clean. However, if you are not using self-hosted version, you can find a Lambda function for your need. After that it can be run on n8n via “AWS Lambda” node.