question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mime.extension is not a function

See original GitHub issue

EDIT: There is nothing to do with the code block below (with if(mail.attachments), it has problem without it as well)

I basically try the code on #16

notifier(imap)
  .on('mail', mail => {
    console.log(mail);
    if(mail.attachments) {
        mail.attachments.forEach(function(attachment){
          console.log('attachment.generatedFileName',attachment.generatedFileName)
            var bufferStream = new stream.Transform();
            bufferStream.push(attachment.content);
            var output = fs.createWriteStream('/tmp/' + attachment.generatedFileName);
            bufferStream.pipe(output);
        });
    }
  })
  .start();

I try an email with a basic image attachment and I got this error:

/Users/yasin/dev/maildeneme/node_modules/mail-notifier/node_modules/mailparser/lib/mailparser.js:1407
        defaultExt = mime.extension(contentType);
                          ^

TypeError: mime.extension is not a function
    at MailParser._generateFileName (/Users/yasin/dev/maildeneme/node_modules/mail-notifier/node_modules/mailparser/lib/mailparser.js:1407:27)
    at MailParser._processStateHeader (/Users/yasin/dev/maildeneme/node_modules/mail-notifier/node_modules/mailparser/lib/mailparser.js:309:61)
    at MailParser._process (/Users/yasin/dev/maildeneme/node_modules/mail-notifier/node_modules/mailparser/lib/mailparser.js:227:22)
    at runCallback (timers.js:800:20)
    at tryOnImmediate (timers.js:762:5)
    at processImmediate [as _immediateCallback] (timers.js:733:5)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
PavelValentovcommented, Jan 30, 2018

I’ve changed the call defaultExt = mime.extension(contentType); to defaultExt = mime.getExtension(contentType);

It works.

0reactions
AtypicalSysAdmincommented, Oct 29, 2021

I’ve changed the call defaultExt = mime.extension(contentType); to defaultExt = mime.getExtension(contentType);

It works.

Cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot get file extension with NodeJS and mime package
When i'm using mime.extension() with 'video/avi' mimetype as param, undefined is returned. What is the solution ? I don't want split file ...
Read more >
How to use the mime.getType function in mime - Snyk
To help you get started, we've selected a few mime. ... destination, copyVersions) { const extension = path.extname(filePath); const objectConfig = { ACL: ......
Read more >
mime - npm
A comprehensive library for mime-type mapping. Latest version: 3.0.0, last published: a year ago. Start using mime in your project by ...
Read more >
TypeError: mime.lookup is not a function - Google Groups
I have solved this problem by myself! step 1. change file : node_modules/._connect@1.9.2@connect/lib/middleware/static.js:143.
Read more >
mimetypes — Map filenames to MIME types — Python 3.11.1 ...
The functions are the normal interface to this module, ... The extensions are not guaranteed to have been associated with any particular data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found