mitmelon / compress
高级文件压缩器,通过将大文件转换为二进制格式并保存为较小的块来减少和加密文件,以便日后使用。
3.0.0
2023-11-06 10:54 UTC
Requires
- php: >=5.6.0
- php-curl-class/php-curl-class: ^9.18
This package is auto-updated.
Last update: 2024-09-12 17:44:17 UTC
README
压缩
高级文件压缩器,通过将大文件减少和加密为更小的块,以二进制格式保存,以便日后使用。许多应用程序支持文件上传,这会消耗系统大量内存。这个库被设计用来减小zip、rar、图片、pdf、word等各种文件或文档的大小。
安装
使用composer安装
composer require mitmelon/compress
用法
require_once __DIR__."/vendor/autoload.php"; // Initialize library class $compress = new Compress\Compress();
仅压缩文件
/** * @param String $filePath * File location to be compressed * @param String $storePath * Path to output compressed binary file to * @param Mixed $options ["removeMeta" => false, "encrypt" => false, "key" => "password", "scanFile" => ["token" => $token, "service" => $service, "csp" => $csp, "region" => $region]] * Options to remove meta, encrypt file and scan content for reputations */ $compress::compressFile($filePath, $storePath, $options = []); //Compress Image file $compress::compressFile(__DIR__.'/image.png', __DIR__.'/image.txt'); // Compress PDF $compress::compressFile(__DIR__.'/file.pdf', __DIR__.'/file.txt');
扫描文件并压缩
使用Pangea的文件智能服务扫描内容以获取文件信息,例如文件状态,从恶意(恶意软件、勒索软件、特洛伊木马、间谍软件、广告软件)到已知良好内容(操作系统文件、已知第三方软件包)。
要使用Pangea的文件智能服务,请创建一个账户并将凭据插入以下选项中。账户创建是免费的。
$options = array("scanFile" => array("token" => "{File_Intel_API_Token}", "service" => 'file-intel', "csp" => 'aws', "region" => 'us')); $compress::compressFile(__DIR__.'/file.pdf', __DIR__.'/file.txt', $options);
解压缩文件
/** * UnCompress Image file [Get original file back from stored binary] * @param String $storePath * Path containing binary file which was compressed * @param String $fileOutputPath * Path to output original file to * @param String $encrypt_key * If your file was encrypted then provide the key for decryption as third argument */ $compress::uncompressFile($storePath, $fileOutputPath, $encrypt_key = null); //Uncompress Image $compress::uncompressFile(__DIR__.'/image.txt', __DIR__.'/image.png'); // Uncompress PDF $compress::uncompressFile( __DIR__.'/file.txt', __DIR__.'/file.pdf')
其他可更改的公共变量
/** * Encryption block chunk size * * @param Int $block */ public int $block = 1024; /** * Compression and Uncompression chunk size * * @param Int $compress_chunk_size */ public int $compress_chunk_size = 100 * 1024 * 1024; // 100 MB /** * Encryption cipher * * @default aes-256-cbc */ public string $cipher = 'aes-256-cbc';
变更日志
此项目的所有重要更改都将在此记录。
[3.0.0] - 2023-06-11
- 🌟 添加Pangea的文件智能服务以获取文件声誉,并仅允许压缩安全内容
- 🌟 更新了压缩器、解压缩器和文件处理器,以处理大文件而不消耗大量内存
- 🌟 修复了错误并更新了文档页面
[2.0.0] - 2022-03-12
- 🌟 添加了AES 256 CBC模式加密
未来更新
- 将文件存储在集中式和去中心化云服务提供商上
支持
如果您喜欢我的项目并希望帮助我继续开发此项目,请点击此链接https://flutterwave.com/donate/oq61dyrjk9xh 进行捐赠。
许可证
在MIT许可证下发布。