Commit 6139b931 authored by Maik Messerschmidt's avatar Maik Messerschmidt
Browse files

Use maennchen/zipstream-php for zip download. #1

parent 519cb925
......@@ -12,7 +12,10 @@ use Illuminate\Http\Request;
use Str;
use Log;
use Zip;
use ZipStream\Option\Archive as ZipOptions;
use ZipStream\ZipStream;
class ResultController extends Controller
{
......@@ -157,14 +160,17 @@ class ResultController extends Controller
}
public function downloadZip() {
$zip = Zip::create("results.zip");
$options = new ZipOptions();
$options->setSendHttpHeaders(true);
$zip = new ZipStream('results.zip', $options);
Result::cursor()->each(function($result) use ($zip) {
$filename = $result->created_at . ".json";
$zip->addRaw($result->getOriginal("data"), $filename);
$zip->addFile($filename, $result->getOriginal("data"));
});
return $zip;
$zip->finish();
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment