Installation guide

echo file_get_contents($signedUrl);
// > Hello!
Amazon S3 stream wrapper
The Amazon S3 stream wrapper allows you to store and retrieve data from Amazon S3 using built-in PHP functions
like file_get_contents, fopen, copy, rename, unlink, mkdir, rmdir, etc.
See Amazon S3 Stream Wrapper.
Syncing data with Amazon S3
Uploading a directory to a bucket
Uploading a local directory to an Amazon S3 bucket is rather simple:
$client->uploadDirectory('/local/directory', 'my-bucket');
The uploadDirectory() method of a client will compare the contents of the local directory to the contents in the
Amazon S3 bucket and only transfer files that have changed. While iterating over the keys in the bucket and
comparing against the names of local files using a customizable filename to key converter, the changed files are
added to an in memory queue and uploaded concurrently. When the size of a file exceeds a customizable
multipart_upload_size parameter, the uploader will automatically upload the file using a multipart upload.
Customizing the upload sync
The method signature of the uploadDirectory() method allows for the following arguments:
public function uploadDirectory($directory, $bucket, $keyPrefix = null, array $options = array())
By specifying $keyPrefix, you can cause the uploaded objects to be placed under a virtual folder in the Amazon
S3 bucket. For example, if the $bucket name is my-bucket and the $keyPrefix is 'testing/', then your files will
be uploaded to my-bucket under the testing/ virtual folder:
https://my-bucket.s3.amazonaws.com/testing/filename.txt
The uploadDirectory() method also accepts an optional associative array of $options that can be used to
further control the transfer.
params Array of parameters to use with each PutObject or CreateMultipartUpload operation
performed during the transfer. For example, you can specify an ACL key to change the ACL of each
uploaded object. See PutObject for a list of available options.
base_dir Base directory to remove from each object key. By default, the $directory passed into the
uploadDirectory() method will be removed from each object key.
force Set to true to upload every file, even if the file is already in Amazon S3 and has not changed.
concurrencyMaximum number of parallel uploads (defaults to 5)
debug Set to true to enable debug mode to print information about each upload. Setting this value to an
fopen resource will write the debug output to a stream rather than to STDOUT.
In the following example, a local directory is uploaded with each object stored in the bucket using a public-read
ACL, 20 requests are sent in parallel, and debug information is printed to standard output as each request is
transferred.
$dir = '/local/directory';
$bucket = 'my-bucket';
$keyPrefix = '';
$client->uploadDirectory($dir, $bucket, $keyPrefix, array(
'params' => array('ACL' => 'public-read'),
'concurrency' => 20,
Amazon Simple Storage Service
109