streaming-s3 is not working on live -Nodejs

322 views Asked by At

I am using streaming-s3 node-modules, which is working fine on my local machine.

But on live it doesn't seem working. I have https enabled on live server.

if i disabled https on live server my uploading is working fine .

Here is my code

exports.uploadFile = function (fileReadStream, awsHeader, cb) {

    //set options for the streaming module
    var options = {
        concurrentParts: 2,
        waitTime: 20000,
        retries: 2,
        maxPartSize: 10 * 1024 * 1024
    };
    //call stream function to upload the file to s3
    var uploader = new streamingS3(fileReadStream, config.aws.accessKey, config.aws.secretKey, awsHeader, options);
    //start uploading
    uploader.begin();// important if callback not provided.

    // handle these functions
    uploader.on('data', function (bytesRead) {
        console.log(bytesRead, ' bytes read.');
    });

    uploader.on('part', function (number) {
        console.log('Part ', number, ' uploaded.');
    });

    // All parts uploaded, but upload not yet acknowledged.
    uploader.on('uploaded', function (stats) {
        console.log('Upload stats: ', stats);
    });

    uploader.on('finished', function (response, stats) {
        console.log(response);
        logger.log('info', "UPLOAD ", response);
        cb(null, response);
    });

    uploader.on('error', function (err) {
        console.log('Upload error: ', err);
        logger.log('error', "UPLOAD Error: ", err);
        cb(err);
    });

Any idea about this

Thanks

1

There are 1 answers

0
Frederic Henri On BEST ANSWER

You need to enable ssl in your client, add sslEnabled option like following

var options = {
    sslEnabled: true,
    concurrentParts: 2,
    waitTime: 20000,
    retries: 2,
    maxPartSize: 10 * 1024 * 1024
};

you can check more about the options you can use http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html