lanyunit / laravel-uploader
集成cos、oss、七牛云、本地上传的包
v1.0.5
2024-10-18 02:45 UTC
Requires
- php: ^8.2
- iidestiny/flysystem-oss: ^4.3
- illuminate/contracts: ^10.0||^11.0
- overtrue/flysystem-cos: ^5.1
- overtrue/flysystem-qiniu: ^3.2
- qcloud_sts/qcloud-sts-sdk: ^3.0.12
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
README
Integrate local
, Tencent Cloud COS
, Alibaba Cloud OSS
, and Qiniu Cloud
uploads
Installation
You can install the package via composer:
composer require lanyunit/laravel-uploader
You can publish the config file with:
php artisan vendor:publish --tag="uploader-config"
This is the contents of the published config file:
return [ 'allow' => [ 'audio' => [ 'mime' => ['audio/mpeg'], 'max_size' => 30 ], 'video' => [ 'mime' => ['video/mp4', 'video/quicktime', 'video/mpeg', 'video/avi'], 'max_size' => 30 ], 'files' => [ 'mime' => '*', 'max_size' => 30 ], 'image' => [ 'mime' => ['image/jpeg', 'image/png', 'image/gif'], 'max_size' => 30 ], ] ];
Configuration
- Add a new disk to your
config/filesystems.php
config:
<?php return [ 'disks' => [ //... 'uploader' => [ 'driver' => 'uploader', 'type' => 'local', // local tencent qiniu aliyun 'max_size' => 30, // 30MB 'expire_time' => 30 * 60, // seconds 'callback_url' => '', // upload callback url 'prefix' => 'image', // upload directory prefix 'qiniu' => [ "bucket" => "your-bucket" // bucket name, "domain" => "your-domain.com" // assets domain, "access_key" => env('QINIU_ACCESS_KEY'), "secret_key" => env('QINIU_SECRET_KEY') ], 'aliyun' => [ "bucket" => "your-bucket", // bucket name, "isCName" => false, // is custom domain "endpoint" => "oss-cn-shanghai.aliyuncs.com", // your bucket endpoint "access_key_id" => env('ALIYUN_ACCESS_KEY_ID'), "access_key_secret" => env('ALIYUN_ACCESS_KEY_SECRET') ], 'tencent' => [ "app_id" => "your-app-id", // tencent app id "bucket" => "your-bucket", // bucket name, "region" => "ap-beijing", // bucket region "secret_id" => env('TENCENT_SECRET_ID'), "secret_key" => env('TENCENT_SECRET_KEY') ] ], //... ] ];
- Set callback route
<?php use Illuminate\Support\Facades\Route; use Lanyunit\FileSystem\Uploader\Controllers\Callback; Route::post('callback', [Callback::class, 'index']);
Usage
$storage = app('filesystem')->disk('uploader'); // Web Direct Transfer dd($storage->getAdapter()->getTokenConfig('image'));
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.