Is it possible to get email attachment in App Engine Blobstore?

I managed to get email attachments on Amazon S3 from an incoming GAE email, but does anyone know the technique to get an attachment, like an image, in a blobstore.

Any help would be greatly appreciated.

Code so far (using Alex)

upload_url = blobstore.create_upload_url('/upload') msg = MIMEMultipart() msg.set_type('multipart/form-data') msg.set_payload({'file': content}) result = urlfetch.fetch(upload_url, payload=urllib.urlencode(msg), method=urlfetch.POST, headers={'Content-Type': 'multipart/form-data'}) 
+6
google-app-engine blobstore
source share
2 answers

App Engine (version 1.4.3) allows you to directly write data to blobstore .
You no longer need to use the URL method to download.

+2
source share

To receive mail in your GAE application, follow the documents here : in particular, you will receive an instance of the InboundEmailMessage class with a attachments , which, and I quote:

- The list of file attachments is possibly empty. Each value in the list is a tuple of two elements: the name of the file and the contents of the file.

Then, for these GAE documents , you “create a download URL” and in your download handler (usually a subclass of BlobstoreUploadHandler ) you use get_upload to get the BlobInfo instances and put your metadata somewhere, which later allows you to return them. how your application may be required.

Finally, you POST data (you have from attachments , above) to your just created “download URL”, for example. using urlfetch.fetch (with method-POST and standard application/x-www-form-urlencoded encoding payload for the "form", which the user will fill out if they loaded the data directly, which is a "normal" way to put the data in blobstore - for example, you can use urllib.urlencode to prepare the payload).

This "self-delivered" will use another instance of your application to "receive" data in the blobstore (while the instance that received the email is waiting because fetch is synchronous).

+11
source share

All Articles