I am using the method to generate an example zip file.
Unfortunately the output of the zip file does not decompress to the expected input.
public function generateZip(Request $req) {
$response = new StreamedResponse(function()
{
$opt = array(
'comment' => 'test zip file.',
'send_headers'=>true,
);
$zip = new ZipStream\ZipStream('example.zip');
# create a file named 'hello.txt'
$zip->addFile('hello.txt', 'This is the contents of hello.txt');
# finish the zip stream
$zip->finish();
});
return $response;
The file generated example.zip
, and upon unzipping the file unzipped "hello.txt" but it's contents are one blank new line then
…»,V¢íåTÖ‰¸ºí‘ºíbÖ¸4Öå‘úú|Ωíä
My effort has been based off of this code:
My debugging steps started as this:
1) Attempting to generate zip this using Amazon S3 stream
2) Tinkering with settings, removing compression
3) Isolating the problem to the simplest result
4) Adding output buffering & output flush to attempt to intercept any output.
My route is this:
Route::get("/generate-zip", 'myController@generateZip');
Unfortunately my problem was unrelated to the library. I had (I think) accidentally saved a file inside /vendor that had some additional code in it. Wiping the vendor folder and re-installing did the trick.