PHP Classes
elePHPant
Icontem

PHP AWS S3 SDK Wrapper: Retrieve and cache AWS S3 files using the SDK

Recommend this page to a friend!
  Info   Demos   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2015-11-26 (1 year ago) RSS 2.0 feedNot yet rated by the usersTotal: 130 All time: 8,606 This week: 642Up
Version License PHP version Categories
aws-s3-wrapper 1.0.0MIT/X Consortium ...5.4PHP 5, Files and Folders, Cache, Web ...
Description Author

This class can retrieve and cache AWS S3 files using the SDK.

It is a wrapper around Amazon Web Services S3 Storage to store and retrieve files.

The retrieved files can be cache in local files to avoid retrieving again files that were not modified since the cached files were retrieved.

The class can also list the file buckets in a given account and delete file buckets as well with the locally cached copies.

  Performance   Level  
Name: Joseluis Laso <contact>
Classes: 16 packages by
Country: Spain Spain
Age: 49
All time rank: 104820 in Spain Spain
Week rank: 177 Up6 in Spain Spain Up
Innovation award
Innovation award
Nominee: 6x

Winner: 2x

Details

Class

This wrapper allows minimizing S3 access, maintaining a local cache (on server).

Installation

add to the composer.json file of your project {

...
"require": {
   ...
   "jlaso/aws-s3-wrapper": "dev-master",
   ...
}

}

and run `composer update`

or run


#Configuration

You can use the src/config.ini  (created from src/config.ini.sample)  in order to simplify access to the wrapper with
S3Wrapper::getInstance().

Or you can create your own instance passing the data the wrapper needs to be created:
new S3Wrapper($accessKey, $secretKey, $bucket);

#Permissions
You have to create cache folder and give 0755 permissions. Likely you have to change the owner/group to apache user/group.

#Test
In order to OOB test you can use the file samples/basic.php.

#Use

###Fetch the content o a file.

$s3 = new S3Wrapper($access, $secretm $bucket); $s3->getFileIfNewest($localFile, $remoteFile); // you have now the contents of $remoteFile on $localFile


###Save a file.

$s3 = new S3Wrapper($access, $secretm $bucket); $s3->saveFile($remoteFile, $content);


###Get the list of files.

$s3 = new S3Wrapper($access, $secretm $bucket); $fileList = $s3->getFilesList($path);


###Delete a file

$s3 = new S3Wrapper($access, $secretm $bucket); $s3->deleteFile($localFile, $remoteFile);

  Online demoExternal page  

Open in a separate window

  Files folder image Files  
File Role Description
Files folder imagesamples (1 file)
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  samples  
File Role Description
  Accessible without login Plain text file basic.php Example Example script

  Files folder image Files  /  src  
File Role Description
  Accessible without login Plain text file config.ini.sample Data Auxiliary data
  Plain text file S3Wrapper.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:130
This week:0
All time:8,606
This week:642Up