overtrue/laravel-filesystem-qiniu
Laravel filesystem Qiniu
Qiniu storage for Laravel based on overtrue/flysystem-qiniu.
Requirement
- Laravel >= 9.0
Installation
$ composer require "overtrue/laravel-filesystem-qiniu"
Configuration
- After installing the library, register the
Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProviderin yourconfig/app.phpfile:
'providers' => [
// Other service providers...
Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProvider::class,
],
- Add a new disk to your
config/filesystems.phpconfig:
<?php
return [
'disks' => [
//...
'qiniu' => [
'driver' => 'qiniu',
'access_key' => env('QINIU_ACCESS_KEY', 'xxxxxxxxxxxxxxxx'),
'secret_key' => env('QINIU_SECRET_KEY', 'xxxxxxxxxxxxxxxx'),
'bucket' => env('QINIU_BUCKET', 'test'),
'domain' => env('QINIU_DOMAIN', 'xxx.clouddn.com'), // or host: https://xxxx.clouddn.com
],
//...
]
];
Usage
$disk = Storage::disk('qiniu');
// create a file
$disk->put('avatars/filename.jpg', $fileContents);
// check if a file exists
$exists = $disk->has('file.jpg');
// get timestamp
$time = $disk->lastModified('file1.jpg');
// copy a file
$disk->copy('old/file1.jpg', 'new/file1.jpg');
// move a file
$disk->move('old/file1.jpg', 'new/file1.jpg');
// get file contents
$contents = $disk->read('folder/my_file.txt');
// fetch url content
$file = $disk->getAdapter()->fetch('folder/save_as.txt', $fromUrl);
// get file url
$url = $disk->getAdapter()->getUrl('folder/my_file.txt');
// get file upload token
$token = $disk->getAdapter()->getUploadToken('folder/my_file.txt');
$token = $disk->getAdapter()->getUploadToken('folder/my_file.txt', 3600);
// get private url
$url = $disk->getAdapter()->privateDownloadUrl('folder/my_file.txt');
:heart: Sponsor me
如果你喜欢我的项目并想支持它,点击这里 :heart:
Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
License
MIT
Related Packages
doctrine/dbal
Powerful PHP database abstraction layer (DBAL) with many features for database s...
644,549,754
9,698
laravel/serializable-closure
Laravel Serializable Closure provides an easy and secure way to serialize closur...
423,477,751
607
nunomaduro/collision
Cli error handling for console/command-line PHP applications.
399,241,428
4,660
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v3.0.0 | ^13.0 | MIT | ||
| 2.4.0 | ^9.0| | MIT | ||
| 2.3.0 | ^9.0| | MIT | ||
| 2.2.1 | ^9.0| | MIT | ||
| 2.2.0 | ^9.0| | MIT | ||
| 2.1.0 | ^9.0 | MIT | ||
| 2.0.4 | ^9.0 | MIT | ||
| 2.0.3 | ^9.0 | MIT | ||
| 2.0.2 | ^9.0 | MIT | ||
| 2.0.1 | ^9.0 | MIT | ||
| 2.0.0 | ^9.0 | MIT | ||
| 1.0.2 | >=5.5.9 | MIT | ||
| 1.0.1 | >=5.5.9 | MIT | ||
| 1.0.0 | >=5.5.9 | MIT | ||
| 0.0.3 | >=5.5.9 | MIT | ||
| 0.0.2 | >=5.5.9 | MIT | ||
| 0.0.1 | >=5.5.9 | MIT |