python - send data from blobstore as email attachment in GAE -
why isn't code below working? email received, , file comes through right filename (it's .png file). when seek open file, doesn't open correctly (windows gallery reports can't open photo or video
, the file may unsupported, damaged or corrupted
).
when download file using subclass of blobstore_handlers.blobstoredownloadhandler
(basically exact handler gae docs), , same blob key, works fine , windows reads image.
one more bit of info - binary files download , email appear similar, have different length.
anyone got ideas on how can email attachments sending gae blobstore? there similar questions on s/o, suggesting other people have had issue, there don't appear conclusions.
from google.appengine.api import mail service google.appengine.ext import blobstore def send_forum_post_notification(): blob_reader = blobstore.blobreader('my_blobstore_key') blob_info = blobstore.blobinfo.get('my_blobstore_key') value = blob_reader.read() mail.send_mail( sender='my.email@address.com', to='my.email@address.com', subject='this subject', body='hi', reply_to='my.email@address.com', attachments=[(blob_info.filename, value)] ) send_forum_post_notification()
i not understand why utilize tuple attachment. utilize :
message = mail.emailmessage(sender = ...... message.attachments = [blob_info.filename,blob_reader.read()]
python google-app-engine blobstore
No comments:
Post a Comment