In Windows 10, a ZIP compressed file (based on ZipStream PHP), based on 360 compression and decompression is successful, and the decompression based on WinRAR fails
1. Reference: In Laravel 6, based on ZipStream PHP, stream the zip file to the S3 bucket. Reference: Generate a stream resource based on Fopen in PHP 7.4, operate the disk, and adjust it to a memory-based implementation. The compression and decompression is successful based on 360, and the decompression based on WinRAR fails. as shown in Figure 1
2. Use 7Z to decompress on Linux. Although it can be decompressed, there is still an error message. as shown in Figure 2
ERRORS:
Unexpected end of archive
--
Path = assets_new.zip
Type = zip
ERRORS:
Unexpected end of archive
Physical Size = 781844
Archives with Errors: 1
Open Errors: 1
3. Reference:https://maennchen.dev/ZipStream-PHP/guide/FlySystem.html. Before uploading the stream, you need to execute: $zip->finish();
Before adjustment:
$name = $this->themeInstallationTask->themeInstallation->theme_id . '/assets.zip';
$stream = fopen('php://memory', 'w+');
$options = new Archive();
$options->setOutputStream($stream);
$zip = new ZipStream($name, $options);
$zip->addFile(str_replace('\\', '/', str_replace(self::$destination . '/', '', $file->getPathname())), $file->getContents());
Storage::disk(config('theme_asset.filesystem.disk'))->putStream(
$name,
$stream,
config('theme_asset.filesystem.options')
);
$zip->finish();
fclose($stream);
After adjustment:
$name = $this->themeInstallationTask->themeInstallation->theme_id . '/assets.zip';
$stream = fopen('php://memory', 'w+');
$options = new Archive();
$options->setOutputStream($stream);
$zip = new ZipStream($name, $options);
$zip->addFile(str_replace('\\', '/', str_replace(self::$destination . '/', '', $file->getPathname())), $file->getContents());
$zip->finish();
Storage::disk(config('theme_asset.filesystem.disk'))->putStream(
$name,
$stream,
config('theme_asset.filesystem.options')
);
fclose($stream);
4. The compression and decompression is successful based on 360, and the decompression is successful based on WinRAR.

