title: Save image from URL to S3 in node.js
body: <p>I would like to be able to save images from URL to S3. I've been able to do something similar by allowing users to upload profile pictures by using this code (<a href="http://sailsjs.com/documentation/concepts/file-uploads/uploading-to-s-3" rel="nofollow noreferrer">docs here</a>): </p>
  
  <pre><code>uploadUserImage: function(req, res) {
      var userName = req.params.username;
      var fname = userName + ".jpg";
      var userAvatar = "https://.......;
  
      req.file('image').upload({
        adapter: require('skipper-s3'),
        key:'xxxxxxxxxxxx',
        secret:'xxxxxxxxxx',
        region: "xxxxxx",
        bucket: 'xxxxxxx',
        headers: {
          ACL: 'public-read'
        },
        saveAs: "user-images/"+fname
      }, function whenDone(err, uploadedFiles) {
  </code></pre>
  
  <p>Is there anyway I could modify this code so I can save images from a URL/ link? </p>
  
  <p>I've been trying to do something like this but I can't figure out how it would work.</p>
  
  <pre><code>var request = require('request');
  function(person, next) {
  
        request({
            url:person.image,
            encoding:null
        }, function(err, res, reqBody) {
            if (err) {
                console.log(err);
            } else {
                console.log(reqBody);
                console.log(res);
            }
        reqBody.upload({
         adapter: require('skipper-s3'),
         key:'xxxxxxxxxxxx',
         secret:'xxxxxxxxxx',
         region: "xxxxxx",
         bucket: 'xxxxxxx',
         headers: {
          ACL: 'public-read'
        },
          saveAs: "user-images/"+person.id+".jpeg"
        }, function whenDone(err, uploadedFiles) {
              if(err) {
                  return next(err);
              } else {
                  person.image = "https:........";
                  return next(null, person);
              }
          });
      });
  
    },
  </code></pre>