AWS Educate Starter帐户中S3的aws_access_key_id

时间:2019-04-12 13:17:33

标签: amazon-web-services amazon-s3

aws_access_key_id用于使用php将文件上传到S3在AWS Educate Starter帐户中不起作用,但是相同的aws_access_key_id在AWS CLI中也起作用。 代码:

<?php
    if(isset($_FILES['image'])){
        $file_name = $_FILES['image']['name'];   
        $temp_file_location = $_FILES['image']['tmp_name']; 

        require 'vendor1/autoload.php';

        $s3 = new Aws\S3\S3Client([
            'region'  => 'us-east-1',
            'version' => 'latest',
            'credentials' => [
                'key'    => "ASIAUHXXXXVM5R6YKHYGS",
                'secret' => "L3/PRCmu8styPcTY5GXXXXXXXX",
                ]
        ]);     

        $result = $s3->putObject([
            'Bucket' => 'demofast',
            'Key'    => $file_name,
            'SourceFile' => $temp_file_location         
        ]);

        var_dump($result);
    }
?>

<form action="<?= $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">         
    <input type="file" name="image" />
    <input type="submit"/>
</form> 

错误:您提供的AWS访问密钥ID(已截断...)InvalidAccessKeyId(客户端):您提供的AWS访问密钥ID在我们的记录中不存在

0 个答案:

没有答案