Permalink
Browse files

fix requestHandlers /show for showing image after upload.

  • Loading branch information...
1 parent 083874e commit 3dabe6823d291887fca2b5d1c8493bc21bd9e103 @ha-minh-vuong ha-minh-vuong committed Jun 11, 2013
Showing with 2 additions and 11 deletions.
  1. +2 −11 code/application/requestHandlers.js
@@ -49,17 +49,8 @@ function upload(response, request) {
function show(response) {
console.log("Request handler 'show' was called.");
- fs.readFile("/tmp/test.png", "binary", function(error, file) {
- if(error) {
- response.writeHead(500, {"Content-Type": "text/plain"});
- response.write(error + "\n");
- response.end();
- } else {
- response.writeHead(200, {"Content-Type": "image/png"});
- response.write(file, "binary");
- response.end();
- }
- });
+ response.writeHead(200, {"Content-Type": "image/png"});
+ fs.createReadStream("/tmp/test.png").pipe(response);
}
exports.start = start;

1 comment on commit 3dabe68

@Vagic
Vagic commented on 3dabe68 Jan 23, 2015

When I downloaded the code from this repository, I receive below error. Please assist to fix the issue.

C:\A Work\Study\NodeJs\Code>node index.js
module.js:340
throw err;
^
Error: Cannot find module 'formidable'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (C:\A Work\Study\NodeJs\Code\requestHandlers.js:3:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

Please sign in to comment.