Getting file upload from AWS S3

Alex Lord
Alex Lord used Ask the Experts™
on
Hey

So i use Amazon S3 upload file to store uploaded Files,

Now what im trying to do is  a custom attach document to a email which i am using phpmailer to attach, my issue is im not sure how to get the file from Amazon S3 and attach it to the PHPMailer.

I have only front end and jq setup, where you click on a attachment which sends a ajax request to the backend which uses a file path to go to the S3 but im not sure how to bring back the file to pass into phpMailer.

any tips or advice ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
To accomplish this, "Now what im trying to do is  a custom attach document to a email which i am using phpmailer to attach, my issue is im not sure how to get the file from Amazon S3 and attach it to the PHPMailer."

You will do this...

1) No mail client has the ability to access an S3 asset, so you must make this asset available to mail clients.

2) If the asset is large, you'll download it from S3 to some public facing Website + reference the URL in your email.

3) If the asset is small, you'll download it from S3 to local storage, then embed an inline version of the asset in your email, then delete the local asset when you're finished sending your email.
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
There is a PHP Wrapper class that allows you to interact with S3 to get files you can find it here
https://www.phpclasses.org/package/4144-PHP-Stream-wrapper-to-get-and-send-files-to-Amazon-S3.html

I have not used it but it appears to cater for what you need to do

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial