How to send an attachment within an email task?

View in #prefect-community on Slack

Prasanth_Kothuri @Prasanth_Kothuri: Hello, is there an example of how I add s3 file as an attachment to prefect email task , I looked at the code and the current attachments param only support local uri , TIA

Kevin_Kho @Kevin_Kho: I haven’t seen a ready example. You’d have to make your own version of the task and modify the existing task. I think you’d need to download that s3 file first

Anna_Geller @Anna_Geller: @Prasanth_Kothuri sending attachments in automated email tasks is difficult since attachments are generally considered a security risk. Is there any reason you couldn’t send just a link to the S3 object in your email text message?

I remember I had a similar use case in the past and solved it using presigned URLs in S3. Basically, you send a normal email message, but within your message, you send a presigned URL that allows downloading the S3 object with a single click from within the email with no extra authentication because the URL is already presigned to be authenticated for up to 6 hours. LMK if you are interested in seeing an example.

Prasanth_Kothuri @Prasanth_Kothuri: thats a great idea, our s3 is based on openstack ceph storage, I will check if we have presigned URL functionality

Anna_Geller @Anna_Geller: This is an S3 feature available to everyone :slight_smile:
here is an example from my older blog post

Prasanth_Kothuri @Prasanth_Kothuri: you are right I could do that with s3cmd signurl so any API would work as well, thanks a ton