Installation guide

PHP's fopen() function requires that a $mode option is specified. The mode option specifies whether or not data can
be read or written to a stream and if the file must exist when opening a stream. The Amazon S3 stream wrapper
supports the following modes:
rA read only stream where the file must already exist.
wA write only stream. If the file already exists it will be overwritten.
aA write only stream. If the file already exists, it will be downloaded to a temporary stream and any writes to the
stream will be appended to any previously uploaded data.
xA write only stream. An error is raised if the file does not already exist.
Other object functions
Stream wrappers allow many different built-in PHP functions to work with a custom system like Amazon S3. Here
are some of the functions that the Amazon S3 stream wrapper allows you to perform with objects stored in Amazon
S3.
unlink() Delete an object from a bucket.
// Delete an object from a bucket
unlink('s3://bucket/key');
You can pass in any options available to the DeleteObject operation to modify how the object is
deleted (e.g. specifying a specific object version).
// Delete a specific version of an object from a bucket
unlink('s3://bucket/key', stream_context_create(array(
's3' => array('VersionId' => '123')
));
filesize() Get the size of an object.
// Get the Content-Length of an object
$size = filesize('s3://bucket/key', );
is_file() Checks if a URL is a file.
if (is_file('s3://bucket/key')) {
echo 'It is a file!';
}
file_exists() Checks if an object exists.
if (file_exists('s3://bucket/key')) {
echo 'It exists!';
}
filetype() Checks if a URL maps to a file or bucket (dir).
file() Load the contents of an object in an array of lines. You can pass in any options available to the
GetObject operation to modify how the file is downloaded.
filemtime() Get the last modified date of an object.
rename() Rename an object by copying the object then deleting the original. You can pass in options
available to the CopyObject and DeleteObject operations to the stream context parameters
to modify how the object is copied and deleted.
Amazon S3 Stream Wrapper
133