def receive(self, mail_message): logging.info("Received a message from: " + mail_message.sender) images = mail_message.bodies("image/jpeg") req = StitchRequest(mail_message.sender, "batchx", config.gs_bucket) for file, attachment in mail_message.attachments: logging.info("attachment: %s" % file) file = file.lower().replace(" ", "") if not (file.endswith(".jpg") or file.endswith(".jpeg")): continue logging.info("writing %s, %d bytes" % (file, len(attachment))) req.AddFile(file, attachment) logging.info("%s" % req.toJson())
def receive(self, mail_message): logging.info("Received a message from: " + mail_message.sender) images = mail_message.bodies('image/jpeg') req = StitchRequest(mail_message.sender, 'batchx', config.gs_bucket) for file, attachment in mail_message.attachments: logging.info('attachment: %s' % file) file = file.lower().replace(' ', '') if not (file.endswith('.jpg') or file.endswith('.jpeg')): continue logging.info('writing %s, %d bytes' % (file, len(attachment))) req.AddFile(file, attachment) logging.info('%s' % req.toJson())
def get(self, batch='stitched'): """Handle HTTP POST requests.""" batch = self.request.get('batch') or batch logging.info('batch name: %s' % batch) # for non-multipart #data = self.request.body_file data = cStringIO.StringIO(self.request.get('file')) archive = zipfile.ZipFile(data, 'r') user = users.get_current_user() req = StitchRequest(user.email(), batch, config.gs_bucket) for info in archive.infolist(): # 2.6 image = archive.open(info.filename).read() image = archive.read(info.filename) logging.info('%s/%d bytes' % (info.filename, len(image))) req.AddFile(info.filename, image) logging.info('%s' % req.toJson()) q = taskqueue.Queue('photostitch') tasks = [] tasks.append(taskqueue.Task(payload=req.toJson(), method='PULL')) q.add(tasks)