/**
 * VideoController
 *
 * @description :: Server-side logic for managing videos
 * @help        :: See http://links.sailsjs.org/docs/controllers
 */

module.exports = {
	
  /**
   * `VideoController.create()`
   * Usage: POST /api/video
   */
  create: function (req, res) {
    Video.create(req.body).exec(function (err, video) {
      if (err) throw err;
      res.json(video);
    });
  },

  /**
   * `VideoController.read()`
   * Usage: GET /api/video/:id
   */
  read: function (req, res) {
    Video.findOne({
      id: req.param('id')
    }).exec(function (err, video) {
      if (err) throw err;
      res.json(video);
    });
  },

  /**
   * `VideoController.readAll()`
   * Usage: GET /api/video
   */
  readAll: function (req, res) {
    Video.find().exec(function (err, videos) {
      if (err) throw err;
      res.json(videos);
    });
  },

  /**
   * `VideoController.destroy()`
   * Usage: DELETE /api/video/:id
   */
  destroy: function (req, res) {
    Video.destroy({
      id: req.param('id')
    }).exec(function (err, video) {
      if (err) throw err;
      res.json(video);
    });
  },


  /**
   * `VideoController.update()`
   * Usage: PUT /api/video/:id
   */
  update: function (req, res) {
    Video.update({
      id: req.param('id')
    }, req.body).exec(function (err, updated) {
      if (err) throw err;
      res.json(updated);
    });
  },


  /**
   * `VideoController.tags()`
   * Usage: 
   */
  tags: function (req, res) {
    return res.json({
      todo: 'tags() is not implemented yet!'
    });
  },

  /**
   * `VideoController.getVideo()`
   * Usage: POST /api/video/getVideo
   * Content: {id: ':id'}
   */
  getVideo: function (req, res) {
    Video.findOne({
      id: req.param('id')
    }).exec(function (err, video) {
      if (err) throw err;
      res.json(video.videoDir);
    });
  }
};


@@ -1835,16 +1835,737 @@
     %7D);%0A
+  %7D,%0A%0A  /**%0A   * %60VideoController.uploadVideo()%60%0A   * Usage: POST /api/video/uploadVideo%0A   * Content: %7Bid: ':id', video: 'attach video file here'%7D%0A  **/%0A  uploadVideo: function (req, res) %7B%0A    req.file('video').upload(%7B%0A      dirname: sails.config.appPath + '/vid/' + req.param('id')%0A    %7D, function (err, uploadedFiles) %7B%0A      if (err) return res.negotiate(err); %0A      %0A      // If no files were uploaded, respond with an error.%0A      if (uploadedFiles.length === 0)%7B%0A        return res.badRequest('No file was uploaded');%0A      %7D%0A%0A      return res.json(%7B%0A        message: uploadedFiles.length + ' file(s) uploaded successfully!',%0A        files: uploadedFiles,%0A        textParams: req.params.all()%0A      %7D);%0A    %7D);%0A
   %7D%0A%7D;%0A%0A

Add uploadVideo API to VideoController