gromnan / s3-zip
在AWS S3或HTTP上读取部分zip文件
v1.0.0
2022-09-05 09:17 UTC
Requires
- php: >=7.4
- ext-zlib: *
- async-aws/s3: ^1.5
- psr/log: ^1.1|^2.0|^3.0
Requires (Dev)
- ext-zip: *
- symfony/phpunit-bridge: ^5.4|^6.0
This package is auto-updated.
Last update: 2024-09-06 17:36:39 UTC
README
您的ZIP存档托管在AWS S3或HTTP(S)服务器上?如何列出存档中的文件或只读取一个文件而不下载整个存档?
此包使用 Range: bytes=%d-%d
标头仅下载列出文件或读取单个文件所需的必要数据块。
安装
使用 composer 安装 gromnan/s3-zip
from packagist。
composer require gromnan/s3-zip
使用方法
use AsyncAws\S3\S3Client; use GromNaN\S3Zip\Archive; use GromNaN\S3Zip\Input\S3Input; use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpKernel\Log\Logger; $logger = new Logger(); $httpClient = HttpClient::create()->setLogger($logger); $s3 = new S3Client([/* AWS Config */], null, $httpClient, $logger); $filename = 's3://my-bucket/path/to/archive.zip'; $input = new S3Input($s3, $filename); $input->setLogger($logger); $archive = new Archive($input); // Get the list for file names in the archive var_dump($archive->getFileNames()); // Downloads and extracts the contents of a single file echo $archive->getFile('path/to/file/in/archive.txt')->getContents();
贡献
欢迎提交拉取请求。对于重大更改,请先打开一个问题来讨论您想更改的内容。
请确保适当更新测试。