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

Recommend this page to a friend!
  Info   Demos   View files (6)   Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 155 All time: 8,778 This week: 233
Version License PHP version Categories
aws-s3-wrapper 1.0.1MIT/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.

Picture of Joseluis Laso
  Performance   Level  
Name: Joseluis Laso <contact>
Classes: 16 packages by
Country: Spain Spain
Age: 52
All time rank: 96220 in Spain Spain
Week rank: 136 5 in Spain Spain
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 demo  

Open in a separate window

  Files  
File Role Description
samples (1 file)
src (2 files)
composer.json Data Auxiliary data
LICENSE Lic. License text
README.md Doc. Documentation

  Files  /  samples  
File Role Description
   basic.php Example Example script

  Files  /  src  
File Role Description
   config.ini.sample Data Auxiliary data
   S3Wrapper.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:155
This week:0
All time:8,778
This week:233

For more information send a message to info at phpclasses dot org.