Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

server: tell user if no file received

  • Loading branch information...
commit 7c2fba52ec4cfede2be78308a11a794f7d0fd078 1 parent d4d40db
@astro astro authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 server.js
View
7 server.js
@@ -27,7 +27,7 @@ function app(app) {
filename: part.filename,
mime: part.mime
} });
- var out = files.addFile({ name: part.filename,
+ out = files.addFile({ name: part.filename,
type: part.mime
});
var received = 0;
@@ -56,7 +56,11 @@ function app(app) {
form.parse(req, function(err, fields, files) { if (!error) error = err; });
req.on('end', function() {
+ if (!out && !error)
+ error = new Error('No file received');
+
if (error) {
+ /* Error */
console.error(error.stack);
res.writeHead(400, HTML_HEADERS);
res.write(template.htmlHead);
@@ -64,6 +68,7 @@ function app(app) {
res.write(template.htmlFoot);
res.end();
} else {
+ /* Success */
res.writeHead(200, HTML_HEADERS);
res.write(template.htmlHead);
res.write(template.thanks);
Please sign in to comment.
Something went wrong with that request. Please try again.