Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: manuelkiessling/nodebeginner.org
base: master
...
head fork: heaventear/NodeBeginnerBook
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 8 additions and 12 deletions.
  1. +8 −12 code/application/requestHandlers.js
View
20 code/application/requestHandlers.js
@@ -32,18 +32,14 @@ function upload(response, request) {
form.parse(request, function(error, fields, files) {
console.log("parsing done");
- /* Possible error on Windows systems:
- tried to rename to an already existing file */
- fs.rename(files.upload.path, "/tmp/test.png", function(err) {
- if (err) {
- fs.unlink("/tmp/test.png");
- fs.rename(files.upload.path, "/tmp/test.png");
- }
- });
- response.writeHead(200, {"Content-Type": "text/html"});
- response.write("received image:<br/>");
- response.write("<img src='/show' />");
- response.end();
+ fs.createReadStream(files.upload.path).
+ pipe(fs.createWriteStream('/tmp/test.jpg').on('close', function(){
+ response.writeHead(200, {"Content-Type": "text/html"});
+ response.write("received image:<br/>");
+ response.write("<img src='/show' />");
+ response.end();
+ }));
+
});
}

No commit comments for this range

Something went wrong with that request. Please try again.