-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from ritishgumber/master
bug fixes
- Loading branch information
Showing
3 changed files
with
23 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
|
||
/* | ||
# CloudBoost - Core Engine that powers Bakend as a Service | ||
# (c) 2014 HackerBay, Inc. | ||
# (c) 2014 HackerBay, Inc. | ||
# CloudBoost may be freely distributed under the Apache 2 License | ||
*/ | ||
|
||
module.exports = function() { | ||
module.exports = function() { | ||
|
||
//get file from gridfs | ||
global.app.get('/appfile/:appId/icon', function (req, res) { | ||
global.app.get('/appfile/:appId/icon', function(req, res) { | ||
|
||
console.log("++++ Stream file from gridfs++++++"); | ||
|
||
var appId = req.params.appId; | ||
var fileName = appId; | ||
var fileName = appId; | ||
|
||
global.mongoService.document.getFile(appId,fileName).then(function(file){ | ||
global.mongoService.document.getFile(appId, fileName).then(function(file) { | ||
if (!file) | ||
res.send(); | ||
|
||
var fileStream=global.mongoService.document.getFileStreamById(appId,file._id); | ||
var fileStream = global.mongoService.document.getFileStreamById(appId, file._id); | ||
|
||
res.set('Content-Type', file.contentType); | ||
res.set('Content-Disposition', 'attachment; filename="' + file.filename + '"'); | ||
res.set('Content-Disposition', 'attachment; filename="' + file.filename + '"'); | ||
|
||
fileStream.on("error", function(err) { | ||
res.send(500, "Got error while processing stream " + err.message); | ||
res.end(); | ||
}); | ||
|
||
fileStream.on("error", function(err) { | ||
res.send(500, "Got error while processing stream " + err.message); | ||
res.end(); | ||
}); | ||
|
||
fileStream.on('end', function() { | ||
res.end(); | ||
res.end(); | ||
}); | ||
|
||
fileStream.pipe(res); | ||
|
||
},function(error){ | ||
}, function(error) { | ||
return res.status(500).send(error); | ||
}); | ||
}); | ||
|
||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters