Created
January 20, 2015 09:00
-
-
Save lutsen/9bd05251f3bd29ee10d2 to your computer and use it in GitHub Desktop.
Serving files from Modulus Cloud Storage with Sails
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
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) ); | |
} | |
}; |
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
module.exports = { | |
// Set sails.config.uploaddir | |
uploaddir: process.env.CLOUD_DIR + '/' | |
}; |
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
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