laravel-zipstream icon indicating copy to clipboard operation
laravel-zipstream copied to clipboard

Issue with S3 saving of the zip file

Open d8vjork opened this issue 7 months ago • 2 comments

I'm using the latest version as of today (5.5), and this is what happens:

Image

The code I've:

foreach ($files as $file) {
            $fileExtension = Str::afterLast($file->path, '.');

            // ... definitions of some variables fetching some data

            $zipStream->add(
                's3://'.config('filesystems.disks.s3.bucket')."/{$file->path}",
                "{$filePath}.{$fileExtension}"
            );
        }

$zipPath = "download_batches/{$downloadBatch->id}";
$zipStream->saveToDisk('s3', $zipPath);

d8vjork avatar May 28 '25 14:05 d8vjork

This one works, so is only related to S3 stored zip files:

$zipStream->cacheToDisk('local', $zipPath);

d8vjork avatar May 28 '25 14:05 d8vjork

Ok no, anyway the package still broken, adds empty zip files...

d8vjork avatar May 28 '25 14:05 d8vjork

I just released v5.6, which fixes an issue with saving a zip file to disk. I think it will resolve the issue you were hitting.

HTTP headers being sent automatically by the underlying zipstream package. I had to suppress those when you don't want a browser download, and are just saving to disk. That should eliminate the "headers already sent" problem.

Let me know if the problem still occurs for you in 5.6.

jszobody avatar Jul 23 '25 20:07 jszobody

@jszobody Perfect, will try once I've time with that project, million thanks!

d8vjork avatar Jul 24 '25 09:07 d8vjork