AWS - > S3 - > Fine Uploader,回调失败区域为false

时间:2017-05-03 03:06:14

标签: node.js amazon-web-services amazon-s3 fine-uploader

我写了这样一个服务器:Link

我的上传脚本看起来像(onpage script):

var uploader = new qq.s3.FineUploader({
        element: document.getElementById("fineUploader"),
        request: {
            endpoint: "bucket.s3-eu-central-1.amazonaws.com",
            accessKey: "accesskey",
        },
        signature: {
            version: 4,
            region: "eu-central-1",
            endpoint: "https:127.0.0.1:8000/s3handler"
        },
        retry: {
            enableAuto: false
        },
        chunking: {
            enabled: true
        },
        paste: {
            targetElement: document,
            promptForName: true
        }
    });

我收到凭据,上传后收到错误消息:

the region 'us-east-1' is wrong; expecting 'eu-central-1'

在节点服务器上,x-amz-credential也返回到区域us-east

vaildkey/vailduntil/us-east-1/s3/aws4_request

但我已在客户端(参见第一个代码)区域添加了签名。 另外,我在expectedHostname中添加了与顶部端点相同的链接, 并使用aws.config.region='eu-central-1';

启动服务器

我错误地认为该地区没有变化?

1 个答案:

答案 0 :(得分:0)

根据Fine Uploader docs,您需要设置一个名为objectProperties的顶级属性,其中包含您的区域(默认为us-east-1,这就是创建您的存储区的原因那个地区有效。)

您的上传器脚本如下所示:

var uploader = new qq.s3.FineUploader({
    element: document.getElementById("fineUploader"),
    objectProperties: {
        region: "eu-central-1"
    },
    request: {
        endpoint: "bucket.s3-eu-central-1.amazonaws.com",
        accessKey: "accesskey",
    },
    signature: {
        version: 4,
        endpoint: "https:127.0.0.1:8000/s3handler"
    },
    retry: {
        enableAuto: false
    },
    chunking: {
        enabled: true
    },
    paste: {
        targetElement: document,
        promptForName: true
    }
});