There is no problem not worth solving, and no technology not worth learning!

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

参考:在 Laravel 6 中基于 ZipStream PHP ,将 zip 文件流式传输到 S3 存储桶。参考:在 PHP 7.4 中基于 fopen 生成一个流资源,操作了磁盘,调整为完全基于内存的实现。基于 360 压缩解压成功,基于 WinRAR 解压缩失败。

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

参考:在 Laravel 6 中基于 ZipStream PHP ,将 zip 文件流式传输到 S3 存储桶。参考:在 PHP 7.4 中基于 fopen 生成一个流资源,操作了磁盘,调整为完全基于内存的实现。基于 360 压缩解压成功,基于 WinRAR 解压缩失败。
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

在 Linux 上用 7z 进行解压,虽然能解压出来,但是其实还是有报错信息
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.

PHP / Laravel / Yii2 Legacy Project Maintenance & Long-Term Technical Support

If your PHP / Laravel / Yii2 project is already in production but needs bug fixing, API troubleshooting, performance optimization, developer handover support, or long-term maintenance, feel free to contact me for remote technical support.

Ideal For:
✅ PHP legacy systems without active maintenance
✅ Laravel / Yii2 project bug fixes
✅ Admin panel feature iterations
✅ RESTful API troubleshooting
✅ MySQL / Redis / Nginx performance issues
✅ Long-term remote part-time maintenance

We can start with a small task:
✅ Production error troubleshooting
✅ API issue analysis
✅ Slow query and performance bottleneck diagnosis
✅ Initial code structure review
✅ Deployment environment and log inspection

If you would like to discuss your project, please contact me and mention: PHP Maintenance Consultation.

Contact Me:
Telegram: @shuijingwan
WeChat: 13980074657
Email: shuijingwanwq@gmail.com

评论

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.