2017-08-29 86 views
0

我正在使用该方法生成示例zip文件。Laravel 5.4中的Zipstream - 数据已损坏

不幸的是,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Öå‘úú|Ωíä 

我的努力已经关闭基于这个代码:

Using ZipStream in Symfony: streamed zip download will not decompress using Archive Utility on Mac OSX

我的调试步骤启动此:

1)试图产生压缩此使用Amazon S3流

2)与设置修改一下,除去压缩

3)分离的问题,以最简单的结果

4)添加输出缓冲&输出平齐试图拦截任何输出。

我的路线是这样的:

Route::get("/generate-zip", '[email protected]');

回答

0

不幸的是我的问题是无关的库。我曾经(我认为)不小心将一个文件保存在供应商内部,其中有一些额外的代码。擦拭供应商文件夹并重新安装的诀窍。