AWS S3-如何解决“我们计算出的请求签名与签名不匹配"错误? [英] AWS S3 - How to fix 'The request signature we calculated does not match the signature' error?

查看:1321
本文介绍了AWS S3-如何解决“我们计算出的请求签名与签名不匹配"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在网上搜索了超过两天,并且可能已经浏览了大多数在线记录的方案和解决方法,但是到目前为止,对我来说没有任何帮助.

I have searched on the web for over two days now, and probably have looked through most of the online documented scenarios and workarounds, but nothing worked for me so far.

我使用的是适用于PHP 5.3的PHP V2.8.7的AWS开发工具包.

我正在尝试使用以下代码连接到我的S3存储桶:

I am trying to connect to my S3 bucket with the following code:

// Create a `Aws` object using a configuration file

        $aws = Aws::factory('config.php');

        // Get the client from the service locator by namespace
        $s3Client = $aws->get('s3');

        $bucket = "xxx";
        $keyname = "xxx";

        try {
            $result = $s3Client->putObject(array(
                'Bucket'        =>      $bucket,
                'Key'           =>      $keyname,
                'Body'          =>      'Hello World!'
            ));
            $file_error = false;
        } catch (Exception $e) {
            $file_error = true;
            echo $e->getMessage();
            die();
        }
        //  

我的config.php文件如下:

My config.php file is as follows:

<?php

return array(
    // Bootstrap the configuration file with AWS specific features
    'includes' => array('_aws'),
    'services' => array(
        // All AWS clients extend from 'default_settings'. Here we are
        // overriding 'default_settings' with our default credentials and
        // providing a default region setting.
        'default_settings' => array(
            'params' => array(
                'credentials' => array(
                    'key'    => 'key',
                    'secret' => 'secret'
                )
            )
        )
    )
);

它产生以下错误:

我们计算出的请求签名与您提供的签名不匹配.检查您的密钥和签名方法.

The request signature we calculated does not match the signature you provided. Check your key and signing method.

我已经检查了我的访问密钥和秘密至少20次,生成了新的密钥,并使用了不同的方法来传递信息(例如,配置文件并在代码中包括凭据),但目前无济于事.

I've already checked my access key and secret at least 20 times, generated new ones, used different methods to pass in the information (i.e. profile and including credentials in code) but nothing is working at the moment.

推荐答案

经过两天的调试,我终于发现了问题...

After two days of debugging, I finally discovered the problem...

我分配给对象的键以一个句点开始,即..\images\ABC.jpg,这导致了错误的发生.

The key I was assigning to the object started with a period i.e. ..\images\ABC.jpg, and this caused the error to occur.

我希望API提供更多有意义的相关错误消息,,,希望这对其他人有所帮助!

I wish the API provides more meaningful and relevant error message, alas, I hope this will help someone else out there!

这篇关于AWS S3-如何解决“我们计算出的请求签名与签名不匹配"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆