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

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

问题描述

我已经建立了一个AWS acct.并尝试将我的第一个程序化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上执行"PutObject"时出错. com/gps-photo.org/mykey.txt "; AWS HTTP错误:客户端错误:PUT https://s3.amazonaws.com/gps-photo.org/mykey.txt导致403 Forbidden响应: AccessDenied 访问被拒绝FC49CD(已截断...) AccessDenied(客户端):访问被拒绝- 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 Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
$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'] . "\n";
} catch (S3Exception $e) {
    echo $e->getMessage() . "\n";
}

如果有人可以帮助我,那就太好了.谢谢. --Len

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天全站免登陆