Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. var assert = require('assert-plus');
  2. var request = require('request');
  3.  
  4. function postParseVideo(req, res, next) {
  5. assert.string(req.body.videoSourceUrl, 'videoSourceUrl');
  6.  
  7. var stream = request.get({uri: req.body.videoSorceUrl});
  8. stream.on('response', function(parseResponse) {
  9. fnThatTakesAReadableStream(parseResponse, function(err, data) {
  10. if (err) {
  11. console.log(err);
  12. next(err);
  13. } else {
  14. res.send(201, null, {Location: data.location});
  15. next();
  16. }
  17. });
  18. });
  19. stream.on('error', function(err) {
  20. console.log(err);
  21. next(err);
  22. });
  23. };
  24.  
  25. return self.emit('error', new Error('options.uri is a required argument'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement