Amazon S3 - 如何修复“我们计算的请求签名与签名不匹配”错误?

Amazon S3 - 如何修复“我们计算的请求签名与签名不匹配”错误?

<p>我已经在网上搜索了两天多,并且可能已经浏览了大多数在线记录的场景和解决方法,但到目前为止没有任何效果。<br /> 我使用的是在 PHP 5.3 上运行的适用于 PHP V2.8.7 的 Amazon开发工具包。<br /> 我正在尝试使用以下代码连接到我的 Amazon S3 存储桶:</p> <pre><code class="lang-">// Create a `Aws` object using a configuration file $aws = Aws::factory('config.php'); // Get the client from the service locator by namespace $s3Client = $aws-&gt;get('s3'); $bucket = &quot;xxx&quot;; $keyname = &quot;xxx&quot;; try { $result = $s3Client-&gt;putObject(array( 'Bucket' =&gt; $bucket, 'Key' =&gt; $keyname, 'Body' =&gt; 'Hello World!' )); </code></pre> <p>我已经在网上搜索了两天多,并且可能已经浏览了大多数在线记录的场景和解决方法,但到目前为止没有任何效果。<br /> 我使用的是在 PHP 5.3 上运行的适用于 PHP V2.8.7 的 Amazon开发工具包。<br /> 我正在尝试使用以下代码连接到我的 Amazon S3 存储桶:</p> <pre><code class="lang-">// Create a `Aws` object using a configuration file $aws = Aws::factory('config.php'); // Get the client from the service locator by namespace $s3Client = $aws-&gt;get('s3'); $bucket = &quot;xxx&quot;; $keyname = &quot;xxx&quot;; try { $result = $s3Client-&gt;putObject(array( 'Bucket' =&gt; $bucket, 'Key' =&gt; $keyname, 'Body' =&gt; 'Hello World!' )); $file_error = false; } catch (Exception $e) { $file_error = true; echo $e-&gt;getMessage(); die(); } My config.php file is as follows: return [ // Bootstrap the configuration file with AWS specific features 'includes' =&gt; ['_aws'], 'services' =&gt; [ // 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' =&gt; [ 'params' =&gt; [ 'credentials' =&gt; [ 'key' =&gt; 'key', 'secret' =&gt; 'secret' ] ] ] ] ]; </code></pre> <p>它产生以下错误:<br /> 我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法。<br /> 我已经检查了我的访问密钥和密码至少20次,并且生成了新的,也使用了不同的方法传递信息(即配置文件和在代码中包含凭据),但目前没有任何效果。</p>
Amazon S3 - 如何修复“我们计算的请求签名与签名不匹配”错误? 2022-09-01 14:35:42
Amazon S3 - 如何修复“我们计算的请求签名与签名不匹配”错误? 0
Amazon S3 - 如何修复“我们计算的请求签名与签名不匹配”错误?
<p>经过两天的调试,我终于发现了问题。。。<br /> 我分配给对象的键以句点开头,即 …\images\ABC.jpg,这导致错误发生。<br /> 我希望 API 提供更有意义和相关的错误消息,唉,我希望这能帮助其他人!</p>