Around the houses, App Engine stylee
I'm quite aware of the depths of my e-stupidity, but the only way I could get an image out of an email attachment sent to a Google App Engine app and uploaded to S3 using Boto, was this absurd backflip (literally).
class LogSenderHandler(InboundMailHandler): def receive(self, message): attachments = [] if message.attachments: if isinstance(message.attachments[0], basestring): attachments = [message.attachments] else: attachments = message.attachments for filename, content in attachments: img = images.Image(content.decode()) if img: img.rotate(360) sitehelpers.upload_to_s3(filename, StringIO(img.execute_transforms(output_encoding=images.JPEG)), message.sender)
Anybody out there in the land of tWeb is welcome to call me on this, but in case you are struggling and need any solution possible, this works a treat for me. Ask Jeremy Clarkson about performance.