简体   繁体   中英

How to use Amazon s3 as a Codeigniter library?

I created a file called awslib.php and put it in the application/libraries folder. These are the contents of awslib.php:

<?php

class Awslib {

    function Awslib()
    {
        require_once('sdk-1.5.6.2/sdk.class.php');
    }
}

Also in the libraries folder is the PHP sdk as a folder named sdk-1.5.6.2 .

On my home controller I am loading the library and instantiating the s3 class:

$this->load->library('awslib');
$s3 = new AmazonS3();

When I load my homepage I get this error:

Fatal error: Class 'AmazonS3' not found in /var/www/application/controllers/home.php on line 23

Why isn't it working?

Note: the problem isn't with s3, I can get it to work fine when I store it outside codeigniter and load the demo files that come with the sdk.

I'm assuming you're using the SDK for PHP directly. Most SDKs don't play nicely in CI unless wrapped up.

I highly recommend using the amazon-s3 library (or rather, the spark ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM