Skip to content

skipperjs/skipper-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

skipper-postgreql adapter

NPM version Build status Dependency Status Code Climate

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

Maintained By

About

Skipper Adapter for PostgreSQL and Sails.js

Resources

Stars

Watchers

Forks

Packages

No packages published