Permalink
Browse files

Changing downloads to multipart and the filename to be added to heade…

…r dynamically
  • Loading branch information...
1 parent 491e006 commit c395786275e16c7d92bceea69ab9480603891c22 @lynxbat lynxbat committed Mar 21, 2012
Showing with 13 additions and 5 deletions.
  1. +11 −1 bin/image_svc.js
  2. +2 −1 image/README
  3. 0 image/iso/README
  4. +0 −1 image/media/README
  5. +0 −2 image/mk/README
View
12 bin/image_svc.js
@@ -29,10 +29,20 @@ app.get('/razor/image/mk*',
path = getPath(stdout);
});
+
+
if (path != null) {
+ var filename = path.split("/")[path.split("/").length - 1];
res.writeHead(200, {'Content-Type': 'application/octet-stream'});
var fileStream = fs.createReadStream(path);
- fileStream.pipe(res);
+ res.setHeader('Content-disposition', 'attachment; filename=' + filename);
+ fileStream.on('data', function(chunk) {
+ res.write(chunk);
+ });
+ fileStream.on('end', function() {
+ res.end();
+ });
+// fileStream.pipe(res);
} else {
res.send("Error", 404, {"Content-Type": "application/octet-stream"});
}
View
3 image/README
@@ -1 +1,2 @@
-This is the default Razor images folder. If no environment variable is set for RAZOR_IMAGES_PATH then this is used by default.
+= This is the default folder for Razor images
+== This can be overridden in the config
View
0 image/iso/README
No changes.
View
1 image/media/README
@@ -1 +0,0 @@
-Used for storing media (ISO) for installation
View
2 image/mk/README
@@ -1,2 +0,0 @@
-Dir used to store MK versions
-default MK is sym-linked to rz_mk_image.iso

0 comments on commit c395786

Please sign in to comment.