Coder Social home page Coder Social logo

cubiclesoft / php-zipstreamwriter Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 2.0 41 KB

A fast, efficient streaming library for creating ZIP files on the fly in pure userland PHP without any external tools, PHP extensions, or physical disk storage requirements.

PHP 100.00%
streaming-zip zip stream stream-http pkzip

php-zipstreamwriter's Issues

New header...

I have seen reference to setting the header:
X-Accel-Buffering: no
when streaming files back through nginx. Is this something you may add to your library.

Enhancements...

  • ability to store a filename different from source (from OpenFile)

  • ability to return the headers instead of using header() function ; with psr objects, you have to use $response->withHeader() function.

Central and local directory mismatch for file?

Steps to reproduce
Try to example code in "Getting Started" to create an archive with one files add in chunks

require_once "support/zip_stream_writer.php";

ZipStreamWriter::StartHTTPResponse("test.zip");

$zip = new ZipStreamWriter();
$zip->Init();

$lastmodified  = mktime(0,1,0);
$lastaccessed = $lastmodified + 60;
$created = $lastmodified - 24 * 60 * 60;

$options = array(
    "last_modified" => $lastmodified,
    "64bit" => true,
    "unix_attrs" => 0644,
    "extra_fields" => array(),
    "comment" => "Best file ever."
);

ZipStreamWriter::AppendNTFSExtraField($options["extra_fields"], $lastmodified, $lastaccessed, $created);

$uid = 1234;
$gid = 1234;
ZipStreamWriter::AppendUNIXExtraField($options["extra_fields"], $lastaccessed, $lastmodified, $uid, $gid);

$zip->OpenFile("Hello2.txt", $options, 0);
$zip->AppendFileData("Hello ");
if ($zip->BytesAvailable() > 65536)  echo $zip->Read();
$zip->AppendFileData("there!");
echo $zip->Read();
$zip->CloseFile();
echo $zip->Read();

$zip->Finalize();
echo $zip->Read();

And running WinZip to try opening it.

Actual behavior
If you try to open it in WinZip, apparently the ZIP file header is readable, but extracting at least some files fails like this:
Capture d’écran 2023-02-27 à 16 18 09

I am looking for advice on how to track down this problem. I try to generate the archive with and without 64bit with same result.
This problem doesn't exist with AddFileFromString method.

Version of ZipStreamWriter for PHP
master

Thanks for your help looking into this.

Jann

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.