Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Commit

Permalink
#38 add GET_URL websocket message
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Apr 3, 2014
1 parent 60245ab commit 9dd0685
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions droppy.js
Expand Up @@ -40,6 +40,7 @@
chalk = require("chalk"),
crypto = require("crypto"),
fs = require("graceful-fs"),
got = require("got"),
http = require("http"),
mime = require("mime"),
mkdirp = require("mkdirp"),
Expand Down Expand Up @@ -644,6 +645,20 @@
});
});
break;
case "GET_URL":
log.info("Attempting to download " + msg.url + " to " + msg.to);
got(msg.url, function (err, data) {
if (err) {
log.error("Error requesting " + msg.url);
log.error(err);
} else {
var dest = path.join(msg.to, path.basename(msg.url));
fs.writeFile(dest, data, {mode: mode.file}), function () {
log.info("Sucessfully saved " + dest);
}
}
});
break;
}
});

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -20,6 +20,7 @@
"clean-css": "~2.1.8",
"cpr": "~0.1.1",
"codemirror": "~4.0.3",
"got": "~0.1.0",
"graceful-fs": "~2.0.3",
"jquery": "~2.1.0",
"mime": "~1.2.11",
Expand Down

1 comment on commit 9dd0685

@colelawrence
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

Please sign in to comment.