执行“PutObject"时出错在 AWS 上,上传失败 [英] Error executing "PutObject" on AWS, upload fails

查看:49
本文介绍了执行“PutObject"时出错在 AWS 上,上传失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个 AWS 账户.并且正在尝试将我的第一个程序化 PUT 放入 S3.我使用控制台创建了一个存储桶并将东西放在那里.我还创建了一个子目录 (myFolder) 并将其设为公开.我创建了 .aws/credentials 文件并尝试使用示例代码,但出现以下错误:

I have established an AWS acct. and am trying to do my first programmatic PUT into S3. I have used the console to create a bucket and put things there. I have also created a subdirectory (myFolder) and made it public. I created my .aws/credentials file and have tried using the sample codes but I get the following error:

https://s3.amazonaws.com 上执行PutObject"时出错/gps-photo.org/mykey.txt";AWS HTTP 错误:客户端错误:PUT https://s3.amazonaws.com/gps-photo.org/mykey.txt 导致 403 Forbidden 响应:AccessDeniedAccess DeniedFC49CD (截断...)AccessDenied(客户端):拒绝访问 -拒绝访问拒绝访问FC49CD15567FB9CD1GTYxjzzzhcL+YyYsuYRx4UgV9wzTCQJX6N4jMWwA39PFaDkK2B9R+FZf8GVM6VvMXfLyI/4abo=

Error executing "PutObject" on "https://s3.amazonaws.com/gps-photo.org/mykey.txt"; AWS HTTP error: Client error: PUT https://s3.amazonaws.com/gps-photo.org/mykey.txt resulted in a 403 Forbidden response: AccessDeniedAccess DeniedFC49CD (truncated...) AccessDenied (client): Access Denied - AccessDeniedAccess DeniedFC49CD15567FB9CD1GTYxjzzzhcL+YyYsuYRx4UgV9wzTCQJX6N4jMWwA39PFaDkK2B9R+FZf8GVM6VvMXfLyI/4abo=

我的代码是

<?php

// Include the AWS SDK using the Composer autoloader.
require '/home/berman/vendor/autoload.php';
use AwsS3S3Client;
use AwsS3ExceptionS3Exception;
$bucket = 'gps-photo.org';
$keyname = 'my-object-key';
// Instantiate the client.
$s3 = S3Client::factory(array(
    'profile' => 'default',
    'region' => 'us-east-1',
    'version' => '2006-03-01'
));
try {
    // Upload data.
    $result = $s3->putObject(array(
        'Bucket' => $bucket,
        'Key'    => "myFolder/$keyname",
        'Body'   => 'Hello, world!',
        'ACL'    => 'public-read'
    ));
    // Print the URL to the object.
    echo $result['ObjectURL'] . "
";
} catch (S3Exception $e) {
    echo $e->getMessage() . "
";
}

如果有人能帮助我,那就太好了.谢谢.--连

If anyone can help me out, that would be great. Thanks. --Len

推荐答案

看起来和我遇到的问题一样.将 AmazonS3FullAccess 策略添加到您的 AWS 账户.

It looks like the same issue I ran into. Add a AmazonS3FullAccess policy to your AWS account.

  • 登录 AWS.
  • 在服务下选择 IAM.
  • 选择用户 > [您的用户]
  • 打开权限标签
  • 将 AmazonS3FullAccess 策略附加到帐户

这篇关于执行“PutObject"时出错在 AWS 上,上传失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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