【问题标题】:Settingup AWS S3 and Codeigniter设置 AWS S3 和 Codeigniter
【发布时间】:2015-02-11 17:26:02
【问题描述】:

我需要将 Amazon S3 与 CI3 一起使用,因此我的计划是创建一个名为 AmazonS3 的库,我将在其中使用 up() delete() tokenize() 之类的基本方法。
我在 application/s3 目录中使用 composer 安装了 S3。
**我的图书馆代码:**

<?php 
defined('BASEPATH') OR exit('u no here!');

use Aws\S3\S3Client;

class AmazonS3 {

private $s3;
private $bucket;

function __construct()
{
    $this->bucket = 'images.secret.com';

    require 'application/s3/vendor/autoload.php';

    $this->s3 = S3Client::factory([
        'key' => 'super-key---',
        'secret' => 'thats-a-long-string'
    ]);
}

public function up()
{
    $this->s3->putObject([
        'Bucket' => $this->bucket,
        'Key' => 'images/test.jpg',
        'Body' => fopen('application/img/test.jpg', 'rb'),
        'ACL' => 'public-read'
    ]);
}

}

这个 up() 方法只是一个测试目的,我从另一个控制器调用它的方式是这样的:

    $this->load->library('amazons3');
    $this->amazons3->up();

这给了我很多错误。我错过了什么?

【问题讨论】:

标签: php codeigniter amazon-web-services amazon-s3


【解决方案1】:

好的,我找到了解决方案,这不是 codeigniter 问题,我错过了出厂设置的区域部分!

【讨论】:

    猜你喜欢
    • 2017-11-19
    • 2017-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-09
    • 2018-06-19
    相关资源
    最近更新 更多