mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
MailParser: Added missing "stream" attribute on Attachment (#10089)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
3
mailparser/mailparser.d.ts
vendored
3
mailparser/mailparser.d.ts
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user