Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add TarStreamer #197

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@ interfasys/lognormalizer/CHANGELOG.md
interfasys/lognormalizer/README.md
interfasys/lognormalizer/composer.json
interfasys/lognormalizer/phpunit.xml
interfasys/lognormalizer/tests
interfasys/lognormalizer/tests

deepdiver1975/tarstreamer/test
79 changes: 43 additions & 36 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
{
"name": "owncloud/3rdparty",
"description": "All 3rdparty components",
"license": "MIT",
"config": {
"vendor-dir": "."
},
"require": {
"sabre/dav" : "2.1.6",
"doctrine/dbal": "2.5.1",
"mcnetic/zipstreamer": "v0.7",
"kriswallsmith/assetic": "1.2.*@dev",
"phpseclib/phpseclib": "~2.0@dev",
"rackspace/php-opencloud": "v1.9.2",
"james-heinrich/getid3": "dev-master",
"jeremeamia/superclosure": "2.0.0",
"ircmaxell/random-lib": "~1.1",
"bantu/ini-get-wrapper": "v1.0.1",
"natxet/CssMin": "dev-master",
"mrclay/minify": "dev-master",
"punic/punic": "1.1.0",
"pear/archive_tar": "~1.4",
"patchwork/utf8": "~1.1",
"symfony/console": "2.6.4",
"symfony/event-dispatcher": "2.6.4",
"symfony/routing": "2.6.4",
"symfony/process": "2.6.4",
"pimple/pimple": "~3.0",
"ircmaxell/password-compat": "1.0.*",
"nikic/php-parser": "~1.1",
"icewind/Streams": "0.2.0",
"swiftmailer/swiftmailer": "@stable",
"guzzlehttp/guzzle": "~5.0",
"league/flysystem": "1.0.4",
"pear/pear-core-minimal": "v1.10.0alpha2",
"interfasys/lognormalizer": "dev-master@dev"
}
"name": "owncloud/3rdparty",
"description": "All 3rdparty components",
"license": "MIT",
"config": {
"vendor-dir": "."
},
"require": {
"sabre/dav": "2.1.6",
"doctrine/dbal": "2.5.1",
"mcnetic/zipstreamer": "v0.7",
"kriswallsmith/assetic": "1.2.*@dev",
"phpseclib/phpseclib": "~2.0@dev",
"rackspace/php-opencloud": "v1.9.2",
"james-heinrich/getid3": "dev-master",
"jeremeamia/superclosure": "2.0.0",
"ircmaxell/random-lib": "~1.1",
"bantu/ini-get-wrapper": "v1.0.1",
"natxet/CssMin": "dev-master",
"mrclay/minify": "dev-master",
"punic/punic": "1.1.0",
"pear/archive_tar": "~1.4",
"patchwork/utf8": "~1.1",
"symfony/console": "2.6.4",
"symfony/event-dispatcher": "2.6.4",
"symfony/routing": "2.6.4",
"symfony/process": "2.6.4",
"pimple/pimple": "~3.0",
"ircmaxell/password-compat": "1.0.*",
"nikic/php-parser": "~1.1",
"icewind/Streams": "0.2.0",
"swiftmailer/swiftmailer": "@stable",
"guzzlehttp/guzzle": "~5.0",
"league/flysystem": "1.0.4",
"pear/pear-core-minimal": "v1.10.0alpha2",
"interfasys/lognormalizer": "dev-master@dev",
"deepdiver1975/tarstreamer": "dev-master"
},
"repositories": {
"deepdiver1975": {
"type": "vcs",
"url": "https://github.com/VicDeo/TarStreamer"
}
}
}
45 changes: 43 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
'GuzzleHttp\\Stream\\' => array($vendorDir . '/guzzlehttp/streams/src'),
'GuzzleHttp\\Ring\\' => array($vendorDir . '/guzzlehttp/ringphp/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'DeepDiver1975\\TarStreamer\\' => array($vendorDir . '/deepdiver1975/tarstreamer/src'),
);
41 changes: 41 additions & 0 deletions composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2692,5 +2692,46 @@
"log",
"normalizer"
]
},
{
"name": "deepdiver1975/tarstreamer",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/VicDeo/TarStreamer.git",
"reference": "0311a060f34bea3ff1f27ada4f34791885678c94"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/VicDeo/TarStreamer/zipball/0311a060f34bea3ff1f27ada4f34791885678c94",
"reference": "0311a060f34bea3ff1f27ada4f34791885678c94",
"shasum": ""
},
"require": {
"php": ">=5.3.8"
},
"time": "2015-09-24 17:05:22",
"type": "library",
"installation-source": "source",
"autoload": {
"psr-4": {
"DeepDiver1975\\TarStreamer\\": "src/"
}
},
"license": [
"MIT"
],
"description": "A library for dynamically streaming dynamic tar files without the need to have the complete file stored on the server.",
"homepage": "https://github.com/DeepDiver1975/TarStreamer",
"keywords": [
"archive",
"php",
"stream",
"tar"
],
"support": {
"source": "https://github.com/VicDeo/TarStreamer/tree/master"
}
}
]
2 changes: 2 additions & 0 deletions deepdiver1975/tarstreamer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./idea

20 changes: 20 additions & 0 deletions deepdiver1975/tarstreamer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Original work Copyright 2007-2009 Paul Duncan <pabs@pablotron.org>
Modified work Copyright 2013 Barracuda Networks, Inc.

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.
145 changes: 145 additions & 0 deletions deepdiver1975/tarstreamer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# ArchiveStream 0.3.0

A library for dynamically streaming dynamic tar or zip files without the need to have the complete file stored on the server. You can specify if you want a tar or a zip; or if you want to have the library figure out the best option based on the user agent string.

## Options

```php
/**
* Construct Parameters:
*
* $name - Name of output file (optional).
* $opt - Hash of archive options (optional, see "Archive Options"
* below).
*
* Archive Options:
*
* comment - Comment for this archive. (zip only)
* content_type - HTTP Content-Type. Defaults to 'application/x-zip'.
* content_disposition - HTTP Content-Disposition. Defaults to
* 'attachment; filename=\"FILENAME\"', where
* FILENAME is the specified filename.
* large_file_size - Size, in bytes, of the largest file to try
* and load into memory (used by
* add_file_from_path()). Large files may also
* be compressed differently; see the
* 'large_file_method' option.
* send_http_headers - Boolean indicating whether or not to send
* the HTTP headers for this file.
* large_files_only - Boolean indicating whether or not to assume
* that all files we are sending are large.
*
* File Options:
* time - Last-modified timestamp (seconds since the epoch) of
* this file. Defaults to the current time.
* comment - Comment related to this file. (zip only)
* type - Type of file object. (tar only)
*
*
* Note that content_type and content_disposition do nothing if you are
* not sending HTTP headers.
*
* Large File Support:
*
* By default, the method add_file_from_path() will send send files
* larger than 20 megabytes along raw rather than attempting to
* compress them. You can change both the maximum size and the
* compression behavior using the large_file_* options above, with the
* following caveats:
*
* * For "small" files (e.g. files smaller than large_file_size), the
* memory use can be up to twice that of the actual file. In other
* words, adding a 10 megabyte file to the archive could potentially
* occupty 20 megabytes of memory.
*
* * For "large" files we use the store method, meaning that the file is
* not compressed at all, this is because there is not currenly a good way
* to compress a stream within PHP
*
* Notes:
*
* If you do not set a filename, then this library _DOES NOT_ send HTTP
* headers by default. This behavior is to allow software to send its
* own headers (including the filename), and still use this library.
*/
```

## Usage

### Stream whole file at a time

A fast and simple streaming archive files for PHP. Here's a simple example:

```php
// Create a new archive stream object (tar or zip depending on user agent)
$zip = ArchiveStream::instance_by_useragent('example');

// Create a file named 'hello.txt'
$zip->add_file('hello.txt', 'This is the contents of hello.txt');

// Add a file named 'image.jpg' from a local file 'path/to/image.jpg'
$zip->add_file_from_path('image.jpg', 'path/to/image.jpg');

// Finish the zip stream
$zip->finish();
```

### Stream each file in parts

This method can be used to serve files of any size (GB, TB).

```php
// Create a new archive stream object (tar or zip depending on user agent)
$zip = ArchiveStream::instance_by_useragent('example');

// Initiate the stream transfer of some_image.jpg with size 324134
$zip->init_file_stream_transfer('some_image.jpg', 324134);

// Stream part of the contents of some_image.jpg
// This method should be called as many times as needed to send all of its data
$zip->stream_file_part($data);

// Send data descriptor header for file
$zip->complete_file_stream();

// Other files can be added here, simply run the three commands above for each file that is being sent

// Explicitly add a directory to the zip (doesn't recurse - useful for empty
// directories)
$zip->add_directory('foo');
$zip->add_directory('foo/bar');

// Finish the zip stream
$zip->finish();
```

## Requirements

* PHP >=5.1.2 (or the [Hash extension](http://php.net/hash)).
* gmp extension

## Limitations

* Only the Zip64 (version 4.5 of the Zip specification) format is supported.
* Files cannot be resumed if a download fails before finishing.

### Other

You can also add comments, modify file timestamps, and customize (or
disable) the HTTP headers. See the class file for details.

## Contributors
- Paul Duncan - Original author
- Daniel Bergey
- Andy Blyler
- Tony Blyler
- Andrew Borek
- Rafael Corral
- John Maguire

## License

Original work Copyright 2007-2009 Paul Duncan <pabs@pablotron.org>
Modified work Copyright 2013-2015 Barracuda Networks, Inc.

Licensed under the MIT License
16 changes: 16 additions & 0 deletions deepdiver1975/tarstreamer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "deepdiver1975/tarstreamer",
"type": "library",
"description": "A library for dynamically streaming dynamic tar files without the need to have the complete file stored on the server.",
"keywords": ["tar", "archive", "stream", "php"],
"homepage": "https://github.com/DeepDiver1975/TarStreamer",
"license": "MIT",
"require": {
"php": ">=5.3.8"
},
"autoload": {
"psr-4": {
"DeepDiver1975\\TarStreamer\\": "src/"
}
}
}
Loading