1
我在S3存儲桶中有原始電子郵件。我正在編寫一個AWS Lambda函數來提取.xls附件並將其保存到另一個S3存儲桶。到目前爲止,我已經通過Lambda閱讀了電子郵件的原始內容,但是如何提取附件?AWS Lambda:如何從原始電子郵件中提取附件(xls)?
s3.getObject({
Bucket: bucketName,
Key: sesNotification.mail.messageId
}, function(err, data) {
if (err) {
console.log(err, err.stack);
context.fail();
} else {
console.log("Raw email:\n" + data.Body);
// Extract xls and copy to bucket
context.succeed();
}
});
附件在電子郵件正文:
------=_Part_3703880_1038025051.1459895117742
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=Book1.xlsx
Content-ID: <[email protected]>
UEsDBBQABgAIAAAAIQDIo800dgEAAAQFAAATAN0BW0NvbnRlbnRfVHlwZXNdLnhtbCCi2QEooAAC
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA