PHP code example of ffogarasi / s3-bucket-stream-zip-php
1. Go to this page and download the library: Download ffogarasi/s3-bucket-stream-zip-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ffogarasi / s3-bucket-stream-zip-php example snippets
// taken from examples/simple.php
// since large buckets may take lots of time we remove any time limits
set_time_limit(0);
\S3BucketStreamZip;
$auth = [
'key' => '*****',
'secret' => '*****',
'region' => 'us-east-1', // optional. defaults to us-east-1
'version' => 'latest' // optional. defaults to latest
];
$stream = new S3BucketStreamZip($auth);
try {
$stream->bucket('testbucket')
->prefix('testfolder') // prefix method adds a trailing '/'
->send('name-of-zipfile-to-send.zip');
} catch (InvalidParameterException $e) {
// handle the exception
echo $e->getMessage();
} catch (S3Exception $e) {
// handle the exception
echo $e->getMessage();
}
$stream->bucket('another-test-bucket')
->prefix('test/')
->addParams([
'MaxKeys' => 1, // array of other parameters
])
->send('zipfile-to-send.zip');
// if prefix is not supplied, entire bucket contents are streamed
$stream->bucket('another-test-bucket')
->send('zipfile-to-send.zip');