Yii 1.1: es3

Extension to access the S3 class for interaction with Amazon S3
21 followers

This extension is used to interact with Amazon S3 using the S3 class created by Donovan Schönknecht (see Resources for link). I wrote this about a year ago and am posting it now simply because of the number of questions about CDNs that have come up today. I added a minimum of direct methods to add to the base class, and for everything else there is a simple 'call' method which will pass through to the base class.

Requirements

Yii 1.1+

CFile Extension (required for using the upload method, otherwise optional)

Usage

Add the following to your app component configuration

's3'=>array(
        'class'=>'ext.s3.ES3',
        'aKey'=>'ADD YOUR AKEY HERE', 
        'sKey'=>'ADD YOUR SKEY HERE',
    ),

The extension assumes that you have CFile Extension configured to use 'file' as the application component name.

Then to upload a file to S3, simply:

// upload the original version
$success = Yii::app()->s3->upload( 'originalfile' , 'uploadedfile', 's3_BucketName' );

Resources

The original S3 class by and documentation by Donovan Schönknecht can be found here: http://undesigned.org.za/2007/10/22/amazon-s3-php-class

Total 8 comments

#16459 report it
TheLunatic83 at 2014/02/26 05:15am
Forr Ddd comment

include(S3.php) [function.include]: failed to open stream: No such file or directory

I don't know if it is a good practice, i solved adding the bold code line "require 'S3.php';" before class definition

require 'S3.php';
 
 class ES3 extends CApplicationComponent
{
 
    private $_s3;
    public $aKey; // AWS Access key
    public $sKey; // AWS Secret key 
    public $bucket;
    public $lastError="";
#15454 report it
Ddd at 2013/11/11 01:23pm
include(S3.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

I'm getting the following error after following the exact instructions and trying to use a function:

include(S3.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

This is in my components array:

's3'=>array(
                            'class'=>'application.extensions.s3.ES3',
                            'aKey'=>'my key', 
                            'sKey'=>'my secret key',
                        ),

Let me know what I can do, thanks!

#14802 report it
allain at 2013/09/10 05:02pm
Bug

When uploading an empty file it checks if it's empty by calling ->size, this property is returns "0.00" in that case, which it equivalent to true.

#10099 report it
sirin k at 2012/10/04 08:55am
is it possible to delete a file in S3 through this extension?

Is there is any way to delete,rename,copy or move in S3 through this extension?

#9703 report it
seng at 2012/09/04 03:12pm
How do you delete an object?

Thanks for the nice extension, upload to s3 went smoothly. I'm eager to know how the extension is supposed to handle deletions. I tried $s3->deleteObject($s3->bucket, $uri), following the convention of $s3->putObjectFile(...), though both methods are static. For me, it throws an exception no such method exists, but I wonder how pubObjectFile worked. I also tried to call the method using class name s3::deleteObject(...), it failed with auth error since the authkey/secret key was not accessible when accessing the method directly. Could anyone please guide how you people are managing deletes?

#8009 report it
wisp at 2012/05/03 08:59am
endpoint

Could you make the endpoint configurable? The default is US but I'm using Ireland.

I've patched it myself but I guess other people will have the same problem :)

#2482 report it
delmi at 2011/01/08 10:51am
thanks!

I'm adding some methods to fit my needs. Many thanks for this wrapper!

Angelo

#2364 report it
Maurizio Domba Cerin at 2010/12/17 04:12am
nice

This extension comes just in time for me...

Leave a comment

Please to leave your comment.

Create extension
Downloads