skipper-postgresql
v0.50.0
Published
Skipper Adapter for PostgreSQL and Sails
Downloads
31
Maintainers
Readme
skipper-postgreql adapter
Streaming Uploads/Downloads using Sails.js and PostgreSQL.
Install
$ npm install skipper-postgresql --save
Usage
config/skipper.js
module.exports.skipper = {
adapter: require('skipper-postgresql'),
connection: {
host: 'localhost',
user: 'postgres',
password: 'postgres'
},
/**
* OR
*
connection: 'postgres://postgres:postgres@localhost:5432/postgres'
*/
/**
* table to store files in
*/
fileTable: 'file'
}
api/controllers/FileController.js
module.exports = {
upload: function (req, res) {
req.file('upload').upload(sails.config.skipper, function (err, files) {
if (err) return res.negotiate(err);
res.ok(files)
})
},
download: function (req, res) {
var SkipperAdapter = sails.config.skipper.adapter;
SkipperAdapter(sails.config.skipper).read(req.param('fd'), function (err, file) {
if (err) return res.negotiate(err);
res.send(new Buffer(file))
})
}
}
License
MIT