andrewrk / node-s3-client

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

Getting "null" when using listObjects(). #186

Open ssshah5 opened 7 years ago

ssshah5 commented 7 years ago

I am able to run functions like listBuckets(), getSignedUrl() etc. However listObjects() doesn't work for me. Its always giving me null. I am using it as follows

var s3 = require('s3');
var client = s3.createClient({
    maxAsyncS3: 20, // this is the default
    s3RetryCount: 3, // this is the default
    s3RetryDelay: 1000, // this is the default
    multipartUploadThreshold: 20971520,
    multipartUploadSize: 15728640, 
    s3Options: {
        accessKeyId: accessKeyId,
        secretAccessKey: secretAccessKey,
        region: region,
        endpoint: endpoint,
        sslEnabled: false
    }
});
var clientS3 = client.s3;
var params = {Bucket: bucketName};
clientS3.listObjects(params, function(err, data) {
if (err) {
res.status(500).send(err);
}
console.log(data);
res.status(200).send(data);
});

Its returning a null and there is no error messages returned. I was reading about it on this forum (https://stackoverflow.com/questions/37732794/aws-s3-listobjects-suddenly-returning-null-data-object-with-message-type-erro) and it asks to set the "correctClockSkew=true". However, I am not sure where to set this value. Any pointers would be much appreciated.

dylantientcheu commented 6 years ago

I have this issue too, I am still unable to make it work. However to set the correctClockSkew: true can be done under the s3Options object see this > s3 config constructor

s3Options: {
    accessKeyId: XXX
    secretAccessKey: XXX,
    correctClockSkew: true,