簡體   English   中英

S3節點模塊,嘗試上載文件時出現ENETUNREACH錯誤

[英]S3 node module, attempting to upload file gives ENETUNREACH error

我正在嘗試將文件上傳到我的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小文件時的控制台日志:

控制台日志

禁用IIS服務以修復我的錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM