andrewrk / node-s3-client

high level amazon s3 client for node.js
MIT License
1k stars 303 forks source link

not able to sync/ upload a local folder to S3 #224

Open ManojKumarHC opened 5 years ago

ManojKumarHC commented 5 years ago

Hi ,

I am trying to sync entire local directory to S3 bucket which is in ap-south-1 , if the bucket is in other region .. syncing a directory is working as expected . in the ap-south-1 region also My code is not throwing any error , it is coming with grace full exit . but the folder is not getting synced / uploaded to S3 . below given my code . Please help me out to solve this . Any help will be greatly appreciated .

const AWS = require('aws-sdk'); const s3 = require('s3');

const awsS3Client = new AWS.S3( { accessKeyId: accessKeyId, secretAccessKey: secretAccessKey, region: 'ap-south-1', signatureVersion: 'v4' });

const client = s3.createClient({ s3Client: awsS3Client } );

var params = { localDir: './' + local1 deleteRemoved: false, // default false, whether to remove s3 objects // that have no corresponding local file.

        s3Params: {
          Bucket: mybucket1,
          Prefix: "/<path>",
          ACL: 'public-read'
        },
};

      var uploader = client.uploadDir(params);
      uploader.on('error', function(err) {
        console.error("unable to sync:", err.stack);
      });
      uploader.on('progress', function() {
        console.log("progress", uploader.progressAmount, uploader.progressTotal);
      });
      uploader.on('end', function() {
        console.log( "done uploading" );
       // delet.postcall( orderno );
      });