1

我正在使用流式 S3 节点模块,它在我的本地机器上运行良好。

但在现场,它似乎不起作用。我在实时服务器上启用了 https。

如果我在实时服务器上禁用 https ,我的上传工作正常。

这是我的代码

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);
    });

关于这个的任何想法

谢谢

4

1 回答 1

0

您需要在客户端中启用 ssl,添加sslEnabled如下选项

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

您可以查看更多关于您可以使用的选项http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html

于 2015-10-02T09:14:18.023 回答