我正在使用该方法生成一个示例zip文件。
不幸的是,zip文件的输出没有解压缩到预期的输入。
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;该文件生成了example.zip,在解压文件时将其解压缩为"hello.txt“,但其内容只有一个空白的新行
…»,V¢íåTÖ‰¸ºí‘ºíbÖ¸4Öå‘úú|Ωíä我的努力基于以下代码:
我的调试步骤是这样开始的:
1)尝试使用亚马逊S3流生成压缩文件
2)修改设置,删除压缩
3)将问题隔离到最简单的结果
4)添加输出缓冲和输出刷新,以尝试拦截任何输出。
我的路线是:
Route::get("/generate-zip", 'myController@generateZip');
发布于 2017-08-30 02:42:52
不幸的是,我的问题与库无关。我(我想)意外地在/vendor中保存了一个文件,其中包含一些额外的代码。擦除供应商文件夹并重新安装就解决了这个问题。
https://stackoverflow.com/questions/45943581
复制相似问题