Skip to content

Instantly share code, notes, and snippets.

@lutsen
Created January 20, 2015 09:00
Show Gist options
  • Save lutsen/9bd05251f3bd29ee10d2 to your computer and use it in GitHub Desktop.
Save lutsen/9bd05251f3bd29ee10d2 to your computer and use it in GitHub Desktop.
Serving files from Modulus Cloud Storage with Sails
module.exports = {
get: function (req, res) {
res.sendfile( sails.config.uploaddir + req.param('dir') + '/' + req.param('file') );
},
// List the app-storage directory
listdir: function (req, res) {
var fs = require('fs');
return res.json( fs.readdirSync(sails.config.uploaddir) );
}
};
module.exports = {
// Set sails.config.uploaddir
uploaddir: process.env.CLOUD_DIR + '/'
};
module.exports.routes = {
'/uploads/:dir/:file': {
controller: 'ImageController',
action: 'get'
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment