【发布时间】:2013-03-21 21:25:42
【问题描述】:
假设应用收到一条消息,has attachments (mail_message.attachments)。现在,我想将消息保存在数据存储中。我不想在那里存储附件,所以我想只保留 blobstore 密钥。我知道我可以write files to blobstore。我的问题:
- 如何从邮件附件中提取文件;
- 如何保留原始文件名;
- 如何在数据存储中存储 blob 密钥(考虑到一封邮件可以包含多个附件,
BlobKeyProperty()在这种情况下不起作用)。
更新。对于(1)the following code可以使用:
my_file = []
my_list = []
if hasattr(mail_message, 'attachments'):
file_name = ""
file_blob = ""
for filename, filecontents in mail_message.attachments:
file_name = filename
file_blob = filecontents.decode()
my_file.append(file_name)
my_list.append(str(store_file(self, file_name, file_blob)))
【问题讨论】:
标签: google-app-engine email blobstore app-engine-ndb