果汁 / 附件
Juice Attachments 插件。
Requires
- php: ^7.2
- hashids/hashids: ~3.0|~4.0
- illuminate/cache: ~5.7|~6.0|~7.0|~8.0
- illuminate/console: ~5.7|~6.0|~7.0|~8.0
- illuminate/database: ~5.7|~6.0|~7.0|~8.0
- illuminate/filesystem: ~5.7|~6.0|~7.0|~8.0
- illuminate/support: ~5.7|~6.0|~7.0|~8.0
- intervention/image: ~2.4
- ralouphie/mimey: ~2.0
Requires (Dev)
- ext-json: *
- mockery/mockery: ~1.2
- orchestra/testbench: ~3.7|~4.0|~5.0
- phpunit/phpunit: ~7.4|~8.0|~9.0
This package is auto-updated.
Last update: 2024-09-27 14:40:42 UTC
README
提供附件控制器并在你的应用路由中使用它。我们负责其他所有事情。
安装
-
运行 composer require 命令
composer require juice/attachments
-
注册
\Juice\Attachments\AttachmentsServiceProvider::class
服务提供者 -
复制配置文件并设置
-
Laravel -
php artisan vendor:publish --provider="Juice\Attachments\AttachmentsServiceProvider"
-
Lumen -
cp vendor/juice/attachments/config/juice-attachments.php config/
(确保配置目录存在)
-
-
运行设置命令
php artisan attachment:setup
-
运行数据库迁移
php artisan migrate
-
设置你的应用路由
-
完成
控制器方法
*:假设路由命名空间为 \Juice\Attachments\Controllers
上传附件
-
端点
AttachmentController@upload
-
方法参数
无
-
查询字符串
无
-
表单数据
-
返回值
成功上传的文件名的数组,例如。
["sjdwd.png", "pweog.pdf", "msptw.jpeg"]
-
路由示例
Route::post('/attachments', 'AttachmentController@upload');
下载附件
-
端点
AttachmentController@download
-
方法参数
-
查询字符串
-
表单数据
无
-
返回值
Symfony\Component\HttpFoundation\BinaryFileResponse
-
路由示例
Route::get('/attachments/{id}', 'AttachmentController@download'); // https://example.com/attachments/sjdwd.png
垃圾附件
-
端点
AttachmentController@trash
-
方法参数
-
查询字符串
无
-
表单数据
无
-
返回值
包含 success 键的 JSON 响应,例如
{ "success": true }
-
路由示例
Route::delete('/attachments/{id}', 'AttachmentController@trash'); // https://example.com/attachments/sjdwd.png