google app engine - How to get the attached file of a received mail using python and store it in a blob property field -
i trying attached file received mail , store blob property in gae datastore. using google app engine python.
the file should added datastore if file excel file. following code shows method have used this. in class 'mail_message.attachments' give list of attachments of received mail. can file name , file content . here have format of file checking whether it's excel file. that's why have used following method.
class logsenderhandler(inboundmailhandler): def receive(self, mail_message): file_format_supported=['application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet','application/vnd.ms-excel'] payload_no in range(len(mail_message.original.get_payload())): one_payload = mail_message.original.get_payload(payload_no) if one_payload.get_content_type() in file_format_supported: uploadfile=files() uploadfile.temp_file=one_payload uploadfile.put()
this code gives me error
property temp_file must convertible blob instance (blob() argument should str instance, not instance)
what want converting payload type "str instance" store blob property.
**is there other method find file type after getting attachment list using mail_message.attachments. file content got attachment list can stored gae datastore blob property after decoding **.
Comments
Post a Comment