Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rest-fs affects bin files #18

Open
aurium opened this issue Aug 21, 2015 · 1 comment
Open

rest-fs affects bin files #18

aurium opened this issue Aug 21, 2015 · 1 comment

Comments

@aurium
Copy link
Contributor

aurium commented Aug 21, 2015

$ npm start
> [email protected] start /**/rest-fs
> node index.js
$ wget http://localhost:3000/usr/share/icons/hicolor/16x16/apps/Thunar.png -O /tmp/Thunar.png
$ f=/usr/share/icons/hicolor/16x16/apps/Thunar.png; node -e "console.log(require('fs').readFileSync('$f'))"
<Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 03 00 00 00 28 2d 0f 53 00 00 00 04 67 41 4d 41 00 00 b1 8f 0b fc 61 05 00 ... >
$ f=/tmp/Thunar.png; node -e "console.log(require('fs').readFileSync('$f'))"
<Buffer ef bf bd 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 03 00 00 00 28 2d 0f 53 00 00 00 04 67 41 4d 41 00 00 ef bf bd ef bf ... >

Image files provided by rest-fs become unreadable. The same may happen with all other binary types.

@aurium aurium changed the title rest-fs is affects bin files rest-fs affects bin files Aug 21, 2015
@aurium
Copy link
Contributor Author

aurium commented Aug 22, 2015

On the file fileserver.js, replace:

  fileDriver.readFile(filePath, encoding, function(err, data) {

by:

  fileDriver.readFile(filePath, null, function(err, data) {

... then the file transmission works.

Well, the problem comes from the default encoding:

  var encoding = req.query.encoding || 'utf8';

Is this really necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant