FAQ
Hello everyone,


Someone know if it's possible read a file when path is case insensitive?


Some providers changes my path. So can't find image for client.


fs.stat(file, function (err, stat) {
var img = fs.readFileSync(file);
res.contentType = path.extname(file);
res.contentLength = stat.size;
res.end(img, 'binary');
});


Thanks,

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAK-qeG-SUXwdYocDMAb2TpFfrY%2BE7DX5sr-rXQkTEXx10UR4sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Ryan Schmidt at Nov 22, 2014 at 4:06 pm

    On Nov 21, 2014, at 11:57 AM, Gonçalo Diogo Bessa wrote:

    Someone know if it's possible read a file when path is case insensitive?


    Some providers changes my path. So can't find image for client.


    fs.stat(file, function (err, stat) {
    var img = fs.readFileSync(file);
    res.contentType = path.extname(file);
    res.contentLength = stat.size;
    res.end(img, 'binary');
    });
    Are you saying you're getting a file-not-found error because you're on a case-sensitive filesystem and the case of the file stored on disk is different from the case with which you're trying to read it? If so, the solution is to use the correct case in your code. If you're asking if there is a way to figure out the correct case programmatically, then that's not the correct solution to use--not in production code. If you read the directory contents you could compare the filenames case-insensitively with the one you're looking for, but on a case-sensitive filesystem there's no guarantee there wouldn't be multiple matches.


    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/E7749CBE-1440-49F0-82B7-F7FA2AAF4CE3%40ryandesign.com.
    For more options, visit https://groups.google.com/d/optout.
  • Gonçalo Diogo Bessa at Nov 24, 2014 at 11:19 am
    Thank you for help Schmidt.



    2014-11-22 4:09 GMT-02:00 Ryan Schmidt <google-2010@ryandesign.com>:
    On Nov 21, 2014, at 11:57 AM, Gonçalo Diogo Bessa wrote:

    Someone know if it's possible read a file when path is case insensitive?


    Some providers changes my path. So can't find image for client.


    fs.stat(file, function (err, stat) {
    var img = fs.readFileSync(file);
    res.contentType = path.extname(file);
    res.contentLength = stat.size;
    res.end(img, 'binary');
    });
    Are you saying you're getting a file-not-found error because you're on a
    case-sensitive filesystem and the case of the file stored on disk is
    different from the case with which you're trying to read it? If so, the
    solution is to use the correct case in your code. If you're asking if there
    is a way to figure out the correct case programmatically, then that's not
    the correct solution to use--not in production code. If you read the
    directory contents you could compare the filenames case-insensitively with
    the one you're looking for, but on a case-sensitive filesystem there's no
    guarantee there wouldn't be multiple matches.


    --
    Job board: http://jobs.nodejs.org/
    New group rules:
    https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/nodejs/E7749CBE-1440-49F0-82B7-F7FA2AAF4CE3%40ryandesign.com
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAK-qeG_A0BAs7vHUWwMHL%3D5TP7nREjtqUzXz74c0Rx7Vr70jSw%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedNov 22, '14 at 3:19a
activeNov 24, '14 at 11:19a
posts3
users2
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase