我已经在网上搜索了两天多,并且可能已经浏览了大多数在线记录的场景和解决方法,但到目前为止对我没有任何帮助。
我使用的是在 PHP 5.3 上运行的适用于 PHP V2.8.7的AWS开发工具包。
我正在尝试使用以下代码连接到我的 Amazon S3 存储桶:
// 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 文件如下:
return [
// Bootstrap the configuration file with AWS specific features
'includes' => ['_aws'],
'services' => [
// 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' => [
'params' => [
'credentials' => [
'key' => 'key',
'secret' => 'secret'
]
]
]
]
];
它产生以下错误:
我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法。
我已经检查了我的访问密钥和秘密至少 20 次,生成了新的,使用了不同的方法来传递信息(即配置文件并在代码中包含凭据),但目前没有任何工作。