Question

How do I attach files to an email from private Amazon S3 bucket?

  • 25 July 2023
  • 6 replies
  • 828 views

Hi! I need to get some file from my private S3 bucket and attach it to a email and send it.

I see there is an option to upload files to S3 but there is no predefined way to download it (it’s an image smaller than 4MB). I have tried using the AWS SDK but it has been impossible to get the file content. (The bucket is private so it cannot be downloaded from an URL as you may think)

Am I doing something wrong? is this possible to achieve? what do you recommend?


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +14

Hi @crz-123 

Good question.

File links need to be publicly accessible direct download links to be used in Zaps.

Help article: https://help.zapier.com/hc/en-us/articles/8496288813453

Hi Troy! thanks for your answer

I have tried downloading it with a webhook, the tests are successful and display an empty field where the file data should be.
 


Is it impossible to download the data? I have some privacy concerns that won’t allow me set them public in S3.

Thanks!

Userlevel 7
Badge +11

Hi @crz-123! 👋

You’d ideally need a Find File action here to locate the file and return the file object so you could attach it to the email without making it public. There’s an existing feature request for this so I’ve gone ahead and added your vote for that so we can let you know if/when that action becomes available in the future.

In the meantime, what trigger are you using for the Zap? It looks like the New or Updated File (Amazon S3) trigger would output a field called File which would contain the file object. So in the attachments field on the action that sends the email you could select that File field which would add it as an attachment. The New or Updated File trigger would run whenever a file is added into a specific bucket or a file in a specific bucket is updated in some way. So I’m wondering if you could trigger the Zap by moving the file to a specific bucket or updating it by adding a tag to it. Would that be a viable option?

If you can’t use that trigger, then does the webhook request have the correct authentication permissions? Looking at the Amazon S3 API documentation for the GetObject endpoint it seems you’d need to have READ access granted: “To use GET, you must have READ access to the object. If you grant READ access to the anonymous user, you can return the object without using an authorization header.” If READ access isn’t granted then perhaps that’s why the file data isn’t being returned? 

Looking forward to hearing from you on this!

Ooh it would be great to have that feature so please take my vote for that!

About the workaround you mention it doesn’t sound possible in my case since I need another trigger in my Zap to have this started. I know there are SubZaps to make it work but it would be possible to get the incorrect S3 files there since simultaneous uploads could end up mixing records.

Related to the Webhook way, it is pretty difficult to authenticate to AWS from Zapier. That feature would be awesome, AWS Signature authentication in the webhooks so that users could connect easier to any AWS services directly their credentials (Postman has it).

And about AWS SDK I had the bucket permissions and downloaded the file, but transfer the data and made it viable as a attachment was impossible (I accomplished attaching that but it was just a .txt file). The way the code is run and the returns are made doesn’t help to debug and check what is going on. For JS and Python ways I’ve received data. I also tested the scripts in my own computer and those worked fine, but the environments are just different. I’ll be looking for any other workaround with my team.

Also thanks for your answer, it is really nice to know you are working in features that eventually will simplify our tasks.

 

Userlevel 7
Badge +6

Hi @crz-123,

Thank you for your detailed feedback. We always appreciate hearing from users about what would make their experience better.

I understand that the workaround might not be suitable for your specific use case due to the need for another trigger and the potential for incorrect S3 files with simultaneous uploads. Sub-Zaps can indeed be tricky in such scenarios.

Your point about AWS Signature authentication in webhooks is well taken. It would indeed make connecting to AWS services directly much simpler. I'll be sure to pass this suggestion along to our team.

Thank you again for your thoughtful feedback. We're committed to improving Zapier and making it as user-friendly as possible, and member insights like yours are invaluable in that process.

We appreciate your patience and understanding as we continue to work on new features and improvements.

Userlevel 1

Make sure the link is publicly available!