【问题标题】:S3 node module, attempting to upload file gives ENETUNREACH errorS3 节点模块,尝试上传文件给出 ENETUNREACH 错误
【发布时间】:2016-03-11 07:13:16
【问题描述】:

我正在尝试将文件上传到我的 Amazon S3 存储桶,但我收到了 ENETUNREACH 错误。我确实有权为我的存储桶上传/删除文件,并且还编辑了 CORS 配置以允许来自所有来源的 POST/GET 请求。我认为这可能是我从某人那里收到的有问题的钥匙。如果碰巧是问题,有什么好方法可以测试我拥有的密钥是否有效?

代码如下:

var s3 = require('s3');

/* Create a client for uploading or deleting files */
var client = s3.createClient({
    maxAsyncS3: 20,     // this is the default 
    s3RetryCount: 3,    // this is the default 
    s3RetryDelay: 1000, // this is the default 
    multipartUploadThreshold: 20971520, // this is the default (20 MB) 
    multipartUploadSize: 15728640, // this is the default (15 MB)
    s3Options: {
        accessKeyId: 'xxxxxxxx',
        secretAccesskey: 'xxxxxxxx',
        region: 'xxxxxxxx'
    },
});

exports.uploadFile = function(fileName, bucket){
    console.log('Uploading File: ' +fileName+'\nBucket: ' +bucket);

    var params = {
        localFile: fileName, 

        s3Params: {
          Bucket: bucket,
          Key: 'testfile',
        },
    };

    var uploader = client.uploadFile(params);
    uploader.on('error', function(err) {
        console.error("unable to upload:", err.stack);

    });

    uploader.on('progress', function() {
        console.log("progress", uploader.progressMd5Amount, uploader.progressAmount, uploader.progressTotal);
    });

    uploader.on('end', function() {
        console.log("done uploading");
    });
};

尝试上传 txt 小文件时的控制台日志:

Console Log

【问题讨论】:

  • 执行console.log(client) 并发布输出。
  • ENETUNREACH 表示您尝试连接的地址的网络无法从该系统访问。 169.x.x.x 不是有效的可路由地址。您是否能够从命令提示符成功 ping 您的 s3 主机名/地址?
  • ping https://s3-us-west-2.amazonaws.com 喜欢@mscdex 建议

标签: javascript node.js amazon-web-services amazon-s3


【解决方案1】:

禁用 IIS 服务来修复我的错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    • 1970-01-01
    • 2015-10-24
    • 2011-06-02
    • 2019-04-17
    • 2014-02-03
    • 2020-02-12
    相关资源
    最近更新 更多