Amazon S3在第一次上传请求时无法正常工作,但在第二次上传时工作

时间:2015-06-27 07:00:23

标签: amazon-web-services amazon-s3

我正在使用Amazon S3 webservice上传我的文件。

        var req = bucket.putObject(params).on('httpUploadProgress', function (progress) {
            ....some action
        }).send(function (err, data) {
            console.log(err);
            ....some action
        });

当我执行上述操作时,它会给我以下错误。

Error: No credentials to load
at i (https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:4:1104)
at i.a [as getCredentials] (https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:4:1645)
at a.u (https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:4:8229)
at a.h [as callListeners] (https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:5:84)
at a.l (https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:4:31779)
at a.v (https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:4:26057)
at a.n (https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:4:21730)
at n.i [as runTo] (https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:5:25078)
at https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:5:25381
at a.<anonymous> (https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc13.min.js:4:21952)

当我再次单击执行上述操作的同一按钮时,这次它正常工作。这是什么问题

1 个答案:

答案 0 :(得分:1)

我猜你的第一次请求时尚未加载凭据。如果您阅读引发此错误的getCredentials的SDK source,则会看到此评论:&#34;如果您想确保在请求之前加载您的凭据,则可以直接使用此方法提供存储在对象中的准确凭证数据&#34;。