Skip to content
This repository has been archived by the owner on Feb 12, 2021. It is now read-only.

unable to sync: Error: Non-file stream objects are not supported with SigV4 in AWS.S3 #175

Open
vmarimuthu opened this issue May 25, 2017 · 20 comments
Milestone

Comments

@vmarimuthu
Copy link

Can you upgrade aws-sdk version?

@woudsma
Copy link

woudsma commented Jul 10, 2017

Does anyone have a workaround for this issue?
I'm able to download files using client.downloadFile, but uploading using client.uploadFile or client.uploadDir gives an error.

Either: NoSuchBucket: The specified bucket does not exist (which is weird, because downloadFile works with the same params)
Or: Error: Non-file stream objects are not supported with SigV4

@bradgreens
Copy link

Since my app was also using serverless I switched to using the serverless s3 client package and it works outside of us-east-1 (e.g. the much newer us-east-2).

@OmgImAlexis OmgImAlexis modified the milestone: Backlog Aug 19, 2017
@DanielApt
Copy link

This is solved by updating the aws-sdk package. It works for me (eu-west-2 region) when I updated the aws-sdk package to v2.100.0.

@LukasBombach
Copy link

Here's a workaround: Use the S3 Client from the latest SDK and pass it on to the s3 client

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

const awsS3Client = new AWS.S3({
    region: 'eu-central-1',
    signatureVersion: 'v4'
});

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

@asharma93
Copy link

@LukasBombach still works 👍

Ran into the SigV4 issue using the webpack-s3-plugin and resorted to adding an upload script with this workaround.

@anon-r-7
Copy link

anon-r-7 commented Apr 5, 2018

Other folks stop just short of a full answer here but not including how to specify credentials in the AWS.S3 client, here's the full version that you'll need:

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

...
  const awsS3Client = new AWS.S3({
    region: process.env.AWS_ZONE,
    accessKeyId: process.env.AWS_ACCESS_KEY_ID,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
    signatureVersion: 'v4',
  });

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

@slavafomin
Copy link

@LukasBombach Thank you sir, you've saved my day.

@manoj-compro
Copy link

manoj-compro commented Jun 19, 2019

@LukasBombach , @ryanostrom
I was also facing the same issue (Error: Non-file stream objects are not supported with SigV4 in AWS.S3) but after updating as per your suggestion I m getting an timeout error somehow. After 100% its end event does not get fired. Thanks in advance. As I m new to this so may be I am missing something here.

Here is the details :
"aws-sdk": "^2.478.0",
"s3": "^4.4.0",

const awsS3Client = new AWS.S3({
accessKeyId: argv.accessKeyId,
secretAccessKey: argv.secretAccessKey,
region: 'us-east-2',
signatureVersion: 'v4'
});

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

let uploaderObj;

  uploaderObj = client.uploadDir(params);


let prevProgress = 0;
uploaderObj.on('progress', function () {
  if (prevProgress !== uploaderObj.progressAmount) {
    console.log(`Progress: ${Math.round(uploaderObj.progressAmount / uploaderObj.progressTotal * 100)}%`);
    prevProgress = uploaderObj.progressAmount;
  }
});

uploaderObj.on('error', (error) => {
  reject(error);
});

uploaderObj.on('end', () => {
  if (prevProgress === 0)
    console.log('Nothing to upload. Already up to date.');
  resolve('Done uploading.');
})

@BlackHole1
Copy link

@manoj-compro me too

@omarandrade
Copy link

@manoj-compro me too, same version of sdk and s3.

@BlackHole1
Copy link

@ManojKumarHC
Copy link

@manoj-compro
Even i am facing same issue , after 100% it is getting timeed out . the folder is not uploading to S3 . Any fix for this

@manoj-compro
Copy link

require('@auth0/s3') worked for me with same API

@ManojKumarHC
Copy link

Bro I did not understood , where i need to use this require('@auth0/s3') , can u share me the complete code . it will be helpfull

@manoj-compro
Copy link

uninstall S3 and install https://www.npmjs.com/package/@auth0/s3 this module as this is an extension of s3 and issue is fixed in @auth0/s3. All other functions/API are same.

in Js file replace require('s3') by require('@auth0/s3')

@ManojKumarHC
Copy link

Thanks bro , Now there is no error thrown . now i am getting "done uploading" but the folder is not getting synced , or uploaded to S3 , here is my code . please check once . help me out this .

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

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

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

console.log( 'my', mybucket1);
    var params = {
        localDir: './' + local1 ,
        deleteRemoved: false, 
        s3Params: {
          Bucket: mybucket1,
          Prefix: "/prefix",
          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" );
  
      })

@bradgreens
Copy link

Nice work Bro

@ManojKumarHC
Copy link

@manoj-compro help me on the above code shared .. now i am getting error as "unable to sync: KMS.NotFoundException: Invalid arn"

@manoj-compro
Copy link

Below is the working code. if still not fix then try by changing region of bucket.

var s3 = require('@auth0/s3');
var s3Client = s3.createClient({
  s3Options: {
    accessKeyId: argv.accessKeyId
    secretAccessKey: argv.secretAccessKey 
    region: 'us-east-2'
  }
});

const params = {
      localDir: './dist',
      deleteRemoved: true,
      s3Params: {
        Bucket: config[argv.env].s3Bucket,
        Prefix: "",
      },
    };

 uploaderObj = s3Client.uploadDir(params);

@emilgeo
Copy link

emilgeo commented Jul 16, 2020

uninstall S3 and install https://www.npmjs.com/package/@auth0/s3 this module as this is an extension of s3 and issue is fixed in @auth0/s3. All other functions/API are same.

in Js file replace require('s3') by require('@auth0/s3')

This solved the issue for us.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests