dev-master
9999999-dev https://github.com/gianksp/cakephp-amazon-s3Amazon S3 Plugin for CakePHP
MIT
The Requires
The Development Requires
cakephp s3 aws
 Wallogit.com
                    
                    2017 © Pedro Peláez
                         Wallogit.com
                    
                    2017 © Pedro Peláez
                    
                    
                    
                    
                
                
            
Amazon S3 Plugin for CakePHP
A CakePHP Plugin to interact with Amazon Web Services S3 objects. This plugin provides a simple and robust methods that can be added to any CakePHP project to complete the following:, (*1)
composer require gianksp/cakephp-amazon-s3:dev-master
Remember to add CakePlugin::load('AmazonS3'); to your app's bootstrap file., (*2)
Then, simply initialise the plugin with your AWS Access key, secret key and the bucket name you wish to work with., (*3)
App::uses('AmazonS3', 'AmazonS3.Lib');
$AmazonS3 = new AmazonS3(array('{access key}', '{secret key}', '{bucket name}'));
The get method retrieves a remote file and saves it locally. So let's say there is the file foo.jpg on S3 and you want to save it locally in /home/me/stuff/photos you'd use the following., (*4)
$AmazonS3->get('foo.jpg' , '/home/me/stuff/photos');
The put method does the reverse of get, and saves a local file to S3., (*5)
$AmazonS3->put('/home/me/stuff/photos/foo.jpg');
You can optionally specifiy a remote directory within the bucket to save the file in. Be sure not to include a starting / in the remote directory string., (*6)
$AmazonS3->put('/home/me/stuff/photos/foo.jpg' , 'some/folder');
To add any additional AWS headers to a put, example to set the file as "public", they can be passed as an array to the amazonHeaders property., (*7)
$AmazonS3->amazonHeaders = array(
    'x-amz-acl' => 'public-read',
    'X-Amz-Meta-ReviewedBy' => 'john.doe@yahoo.biz'
);
$AmazonS3->put('/home/me/stuff/photos/foo.jpg' , 'some/folder');
Deletes a file from S3., (*8)
$AmazonS3->delete('foo.jpg');
Or delete from within a directory in the bucket. Be sure not to include a starting / in the string or you will receive a SignatureDoesNotMatch error:, (*9)
$AmazonS3->delete('some/folder/foo.jpg');
        Amazon S3 Plugin for CakePHP
MIT
cakephp s3 aws