-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attach PDF File stored on AWS S3 Bucket to SendGrid Email via Python (Django) #815
Comments
Hello @sgrobert, My guess is that the Here is an example that may help. And this is the example I recommend you follow. Thanks! With Best Regards, Elmer |
Hi @thinkingserious , Thank you for the swift reply. Pardon on my end as I was out of the country with no access to my laptop over the weekend. Was looking though your code and tried testing with reference to the link provided by your (https://stackoverflow.com/questions/38408253/way-to-convert-image-straight-from-url-to-base64-without-saving-as-a-file-in-pyt/38408285#38408285), I was wondering will there be a file format conflict as I am pretty unsure of the usage of base64. Is base64 more meant for Images or for all files? Since I am requiring to abstract a PDF file from a link via AWS S3. I am currently still receiving an error via the python console after inserting the code as follows: IOError: [Errno 2] No such file or directory
I've double-checked on the codes but can't seem to find any differences from the suggested code provided in (https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/attachment.md). Not sure if you may help to better rectify where I might have gone wrong. Thank you! |
Hi @thinkingserious , Just to add a point that may be helpful to debugging. The current error being thrown (IOError: [Errno 2] No such file or directory), was being caused by this line: in sendmail I can open the PDF file in incognito mode on Chrome, so security approval should not be a key issue being bumped at the moment. So hope this is will in the debugging. |
Hi @thinkingserious , Guess I finally found the solution to the problem. The code you provided I do believe will work essentially. But I have a lingering feel that the problem may lie with potential security encoding with AWS S3 Buckets' files. Thus I have to sought a new search to identify potential pockets of solution as AWS is quite infamous for not having very easily-helpful documentations. Long story short:
Appreciate the support on this issue thus far! ;) |
Thanks for taking the time to report back @sgrobert, we appreciate it! |
You welcome @thinkingserious! Thanks for offering your assistance in the first place! Really appreciate it as well. Cheers! ;) |
Issue Summary
Hi there, I just got on board with SendGrid for the first time and have been trying to attach a Generated PDF that is stored on an AWS S3 Bucket via URL to the SendGrid API v3. The result however, did not download the file and attach it to the email being sent.
Steps to Reproduce
I've looked at a few steps on Github namely,
a. sendgrid/sendgrid-php#480
b. sendgrid/sendgrid-php#729
c. https://github.com/sendgrid/sendgrid-python/blob/master/examples/mail/mail.py
d. https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/attachment.md
But can't seem to find a clear / working example that I may access to implement the codes to pull the AWS S3 link and attach as a PDF attachment to the email.
I've tried primary 2 steps that seem to partially work in code. But only No. 1 did attach a broken PDF and No. 2 just pops up an error that the file cannot be found, which I do trust that the code was meant for a local-file-on-server to be served.
No. 1. Served broken PDF file to Email that can't be opened
No. 2. Error thrown on server console: IOError: [Errno 2] No such file or directory:
Any other information you want to share that is relevant to the issue being reported. Especially, why do you consider this to be a bug? What do you expect to happen instead?
Technical details:
Hope someone may assist me on this as I faced a number of issues and will be posting different issue docs in hopes to address them as soon as possible. Thank you!
The text was updated successfully, but these errors were encountered: