Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6734733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:55:27+00:00 2026-05-26T10:55:27+00:00

I can’t explain any better, because I honestly have no idea why this error

  • 0

I can’t explain any better, because I honestly have no idea why this error exists. First off, here is the code where I get the error:

app.get '/image/:id', (req, res, next) ->
    images.get req.params.id, (err, doc) ->
        if err then next err else
            res.contentType doc._attachments.image.content_type
            img = images.getAttachment doc.id, 'image'
            img.on 'data', (chunk) ->
                res.write chunk, 'binary'
            img.on 'end', ->
                res.end()

I am fairly sure the problem must be in there somewhere. I have an /upload route that redirects to this, to show the uploaded image right away.

And then I get this error:

TypeError: Cannot call method 'replace' of undefined
    at Object.lookup (/home/scan/Javascript/acres/node_modules/express/node_modules/mime/mime.js:62:20)
    at ServerResponse.contentType (/home/scan/Javascript/acres/node_modules/express/lib/response.js:209:43)
    at Object.callback (/home/scan/Javascript/acres/app.coffee:105:13)
    at Object.get (/home/scan/Javascript/acres/node_modules/cradle/lib/cradle.js:316:33)
    at /home/scan/Javascript/acres/app.coffee:100:19
    at callbacks (/home/scan/Javascript/acres/node_modules/express/lib/router/index.js:272:11)
    at param (/home/scan/Javascript/acres/node_modules/express/lib/router/index.js:246:11)
    at param (/home/scan/Javascript/acres/node_modules/express/lib/router/index.js:243:11)
    at pass (/home/scan/Javascript/acres/node_modules/express/lib/router/index.js:253:5)
    at Router._dispatch (/home/scan/Javascript/acres/node_modules/express/lib/router/index.js:280:4)

Of course I wanted to look up what value exactly is giving me the trouble, so I changed the code with some console.log in every nesting. nodemon restarted the app, and it works like a charm, for this image. With this code.

So I upload another, exactly the same error. Code change, restart, works for this image.

So where do I go wrong or do I have to restart on every upload?

EDIT: Some info about the system:

connect-cradle@0.1.0
connect-form@0.2.1
cradle@0.5.7
express@2.4.6
node@0.4.12
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:55:27+00:00Added an answer on May 26, 2026 at 10:55 am

    Note the second line in the call stack:

    at ServerResponse.contentType (/home/scan/Javascript/acres/node_modules/express/lib/response.js:209:43)

    So the error is occurring in your res.contentType call, which passes doc._attachments.image.content_type to mime.lookup, which calls .replace on it. In short, the problem is that doc._attachments.image.content_type is undefined.

    I hope that at least gets you started in your debugging efforts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone maybe tell me why this is not working? I have used echo
Can someone explain the usage of the dollar sign here.. var updateProgressDiv = $get('updateProgressDiv');
can any one tell me how can change this java code into objective c.is
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
I have a jquery bug and I've been looking for hours now, I can't
Can anyone suggest how to underline the title of a UIButton ? I have
Can I have a project that has some parts written in c and other
Can some one confirm me that only one UIWindow instance is possible in any
Can i get the source code for a WAMP stack installer somewhere? Any help
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.