MailParser: Added missing "stream" attribute on Attachment (#10089)

This commit is contained in:
benoit74
2016-07-20 02:14:25 +02:00
committed by Mohamed Hegazy
parent 83f954972e
commit 3a5b669575
2 changed files with 5 additions and 2 deletions

View File

@@ -3,7 +3,7 @@
import mailparser_mod = require("mailparser");
import MailParser = mailparser_mod.MailParser;
import ParsedMail = mailparser_mod.ParsedMail;
import Attachment = mailparser_mod.Attachment;
var mailparser = new MailParser();
@@ -61,7 +61,7 @@ var mp = new MailParser({
streamAttachments: true
})
mp.on("attachment", function(attachment, mail){
mp.on("attachment", function(attachment : Attachment, mail : ParsedMail){
var output = fs.createWriteStream(attachment.generatedFileName);
attachment.stream.pipe(output);
});

View File

@@ -8,6 +8,8 @@
declare module 'mailparser' {
import StreamModule = require("stream");
import Stream = StreamModule.Stream;
import WritableStream = NodeJS.WritableStream;
import EventEmitter = NodeJS.EventEmitter;
@@ -36,6 +38,7 @@ declare module 'mailparser' {
generatedFileName: string; // e.g. 'image.png'
checksum: string; // the md5 hash of the file, e.g. 'e4cef4c6e26037bcf8166905207ea09b'
content: Buffer; // possibly a SlowBuffer
stream: Stream; // a stream to read the attachment if streamAttachments is set to true
}
// emitted with the 'end' event