mrmadclown / laravel-multipart-response
Laravel 多部分响应包。
v1.0
2020-12-21 10:20 UTC
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.2
- illuminate/routing: ^8.19
This package is auto-updated.
Last update: 2024-09-12 15:14:43 UTC
README
安装
composer require mrmadclown/laravel-multipart-response
使用
如果你不使用自动发现,请将 ServiceProvider 添加到 config/app.php 中的 providers 数组
MrMadClown\LaravelMultiPartResponse\ServiceProvider::class,
手动实例化
在这里,你实际上不需要 ServiceProvider。
use MrMadClown\LaravelMultipartResponse\Http\MultipartResponse; $elements = [[ 'name' => 'my-file', 'contents' => fopen('my-file.txt', 'rb'), 'filename' => 'my-file.txt' ]]; return new MultipartResponse($elements);
从目录
这将创建一个包含该目录中所有文件的响应(非递归!)
use MrMadClown\LaravelMultipartResponse\Http\MultipartResponse; return MultipartResponse::fromDirectory('/var/www/html/storage/app/files-to-send');
使用宏
这就是你需要 ServiceProvider 的原因。
$elements = [[ 'name' => 'my-file', 'contents' => fopen('my-file.txt', 'rb'), 'filename' => 'my-file.txt' ]]; return \response()->multipart($elements);