Skip to content

Disable compression when using addFileFromStream(). #161

@mmenavas

Description

@mmenavas

Description of the problem

Is there a particular reason this library does not support zero compression (STORE) when reading files from a stream?

I would like to see this feature because I suspect this would reduce the CPU load when packaging very large files. I'd be more than happy to contribute code if I can get some directions for adding this feature.

Example code

<?php

require '../vendor/autoload.php';

$files = [
    'data.csv' => __DIR__ . '/files/2013/data.csv', // 2.5GB
    'dictionary.pdf' => __DIR__ . '/files/2013/dictionary.pdf', // 2MB
    'methodology.pdf' => __DIR__ . '/files/2013/methodology.pdf', // 5MB
];

$options = new ZipStream\Option\Archive();
$options->setSendHttpHeaders(true);

$zip = new ZipStream\ZipStream('data-2013.zip', $options);

foreach ($files as $zipPath => $serverPath) {
    if ($streamRead = fopen($serverPath, 'r')) {
        $zip->addFileFromStream($zipPath, $streamRead); // This will compress my files no matter what.
    }
}

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

Information

  • ZipStream-PHP version: 2.1
  • PHP version: 7.2

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions