-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 21cb082
Showing
15 changed files
with
524 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor** | ||
.idea/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: php | ||
php: | ||
- 7.1 | ||
- 7.0 | ||
- 5.6 | ||
install: composer install | ||
script: phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2015 Jaisen Mathai <jaisen@jmathai.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# S3BucketStreamZip | ||
|
||
Forked from `jmathai/s3-bucket-stream-zip-php` | ||
|
||
## Overview | ||
This library lets you efficiently stream the contents of an S3 bucket/folder as a zip file to the client. | ||
|
||
Uses v3 of AWS SDK to stream files directly from S3. | ||
|
||
## Installation | ||
Installation is done via composer by adding the a dependency on . | ||
|
||
``` | ||
composer require dlintin/s3-stream-zip-php | ||
composer install | ||
``` | ||
|
||
## Usage | ||
```php | ||
// taken from examples/simple.php | ||
// since large buckets may take lots of time we remove any time limits | ||
set_time_limit(0); | ||
require sprintf('%s/../vendor/autoload.php', __DIR__); | ||
|
||
use Aws\S3\Exception\S3Exception; | ||
use DNL\S3BucketStreamZip\Exception\InvalidParameterException; | ||
use DNL\S3BucketStreamZip\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(); | ||
} | ||
``` | ||
|
||
|
||
```php | ||
$stream->bucket('another-test-bucket') | ||
->prefix('test/') | ||
->addParams([ | ||
'MaxKeys' => 1, // array of other parameters | ||
]) | ||
->send('zipfile-to-send.zip'); | ||
``` | ||
|
||
```php | ||
|
||
// if prefix is not supplied, entire bucket contents are streamed | ||
$stream->bucket('another-test-bucket') | ||
->send('zipfile-to-send.zip'); | ||
``` | ||
|
||
## Laravel 5.4 | ||
- `pa make:provider AWSZipStreamServiceProvider` and copy the contents `examples/AwsZipStreamServiceProvider.php`. | ||
- Make sure your config values are all set. | ||
- Register the provider in `config/app.php`. | ||
|
||
### OR in `config/app.php` | ||
```php | ||
'providers' => [ | ||
... | ||
DNL\S3BucketStreamZip\AWSZipStreamServiceProvider::class, | ||
... | ||
] | ||
``` | ||
|
||
in `config/services.php`, set: | ||
```php | ||
's3' => [ | ||
'key' => '', | ||
'secret' => '', | ||
'region' => '', | ||
'version' => '', | ||
]; | ||
``` | ||
|
||
## Authors | ||
* Jaisen Mathai <jaisen@jmathai.com> - http://jaisenmathai.com | ||
|
||
## Dependencies | ||
* Paul Duncan <pabs@pablotron.org> - http://pablotron.org/ | ||
* Jonatan Männchen <jonatan@maennchen.ch> - http://commanders.ch | ||
* Jesse G. Donat <donatj@gmail.com> - https://donatstudios.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "dlintin/s3-stream-zip-php", | ||
"homepage": "https://github.com/dlintin/s3-stream-zip-php", | ||
"description": "PHP library to efficiently stream contents from an AWS S3 bucket or folder as a zip file", | ||
"keywords": ["amazon","aws","s3","stream","zip","php","download"], | ||
"type": "library", | ||
"license": "MIT", | ||
"support": { | ||
"issues": "https://github.com/dlintin/s3-stream-zip-php/issues" | ||
}, | ||
"require": { | ||
"php": ">=5.3.3", | ||
"dlintin/zipstream-php": "0.1.1", | ||
"aws/aws-sdk-php": "3.*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~5.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"DNL\\S3BucketStreamZip\\": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use DNL\S3BucketStreamZip\S3BucketStreamZip; | ||
|
||
class AWSZipStreamServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = true; | ||
|
||
/** | ||
* Bootstrap the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Register the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->bind(S3BucketStreamZip::class, function($_) { | ||
return new S3BucketStreamZip([ | ||
'key' => config('services.s3.key'), | ||
'secret' => config('services.s3.secret'), | ||
'region' => config('services.s3.region'), | ||
'version' => config('services.s3.version'), | ||
]); | ||
}); | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return [S3BucketStreamZip::class]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
// since large buckets may take lots of time we remove any time limits | ||
set_time_limit(0); | ||
// set a default time zone in case it's not set | ||
date_default_timezone_set('America/Chicago'); | ||
|
||
require sprintf('%s/../vendor/autoload.php', __DIR__); | ||
|
||
use Aws\S3\Exception\S3Exception; | ||
use DNL\S3BucketStreamZip\Exception\InvalidParameterException; | ||
use DNL\S3BucketStreamZip\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('trashtest') | ||
->prefix('trashfolder') | ||
->send('name-of-zipfile-to-send.zip'); | ||
} catch (InvalidParameterException $e) { | ||
echo $e->getMessage(); | ||
} catch (S3Exception $e) { | ||
echo $e->getMessage(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<phpunit bootstrap="tests/bootstrap.php" | ||
colors="true"> | ||
<testsuites> | ||
<testsuite name="Application"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace DNL\S3BucketStreamZip; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class AWSZipStreamServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = true; | ||
|
||
/** | ||
* Bootstrap the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Register the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->bind(S3BucketStreamZip::class, function($_) { | ||
return new S3BucketStreamZip([ | ||
'key' => config('services.s3.key'), | ||
'secret' => config('services.s3.secret'), | ||
'region' => config('services.s3.region'), | ||
'version' => config('services.s3.version'), | ||
]); | ||
}); | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return [S3BucketStreamZip::class]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace DNL\S3BucketStreamZip; | ||
|
||
abstract class Exception extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace DNL\S3BucketStreamZip\Exception; | ||
|
||
use DNL\S3BucketStreamZip\Exception; | ||
|
||
class InvalidParameterException extends Exception | ||
{ | ||
} |
Oops, something went wrong.