var AWS = require('aws-sdk');
var request = require('request');
const stream = require('stream');

function uploadToS3(s3, params, cb) {
  var pass = new stream.PassThrough();

  s3.upload(Object.assign({}, params, { Body: pass }))
    .send(function(err, data) {
      if (err) {
        cb(err, data);
      }
      if (data && data.Location) {
        cb(null, data.Location); // data.Location is the uploaded location
      } else {
        cb(new Error("data.Location not found!"), data);
      }
    });
  return pass;
}
;

module.exports = function(s3) {
  s3 = s3 || new AWS.S3({
    apiVersion: '2006-03-01'
  });

  return {
    urlToS3: function(url, params, callback) {
      var req = request.get(url);
      req.pause();
      req.on('response', function(resp) {
        if (resp.statusCode == 200) {
          if (resp.headers['content-type']) {
            params.ContentType = resp.headers['content-type'];
          }
          if (resp.headers['content-encoding']) {
            params.ContentEncoding = resp.headers['content-encoding'];
          }
            
          req.pipe(uploadToS3(s3, params, callback));
          req.resume();
        } else {
          callback(new Error('request item did not respond with HTTP 200'));
        }
      });
    }
  };
};


@@ -451,17 +451,17 @@
 w Error(
-%22
+'
 data.Loc
@@ -480,9 +480,9 @@
 und!
-%22
+'
 ), d
@@ -671,24 +671,66 @@
 callback) %7B%0A
+      params = Object.assign(%7B%7D, params);%0A
       var re
@@ -856,33 +856,69 @@
 %7B%0A          
-if (resp.
+const headers = resp.headers;%0A%0A          if (
 headers%5B'con
@@ -965,21 +965,16 @@
 tType = 
-resp.
 headers%5B
@@ -1012,25 +1012,31 @@
         
-if (resp.
+%0A          if (
 headers%5B
@@ -1095,21 +1095,16 @@
 oding = 
-resp.
 headers%5B
@@ -1136,28 +1136,16 @@
       %7D%0A
-            
 %0A       

fix some error I don't know why