Skip to content

Commit afca89a

Browse files
committed
Laravel 9
1 parent a59e79b commit afca89a

File tree

4 files changed

+75
-98
lines changed

4 files changed

+75
-98
lines changed

.php_cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

README.md

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
1-
# Laravel filesystem Qiniu
1+
# Laravel filesystem Qiniu
22

33
[Qiniu](http://www.qiniu.com/) storage for Laravel based on [overtrue/flysystem-qiniu](https://github.com/overtrue/flysystem-qiniu).
44

55
[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue)
66

77
# Requirement
88

9-
- PHP >= 5.5.9
9+
- Laravel >= 9.0
1010

1111
# Installation
1212

1313
```shell
14-
$ composer require "overtrue/laravel-filesystem-qiniu" -vvv
14+
$ composer require "overtrue/laravel-filesystem-qiniu"
1515
```
1616

1717
# Configuration
1818

1919
1. After installing the library, register the `Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProvider` in your `config/app.php` file:
2020

21-
```php
22-
'providers' => [
23-
// Other service providers...
24-
Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProvider::class,
25-
],
26-
```
21+
```php
22+
'providers' => [
23+
// Other service providers...
24+
Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProvider::class,
25+
],
26+
```
2727

2828
2. Add a new disk to your `config/filesystems.php` config:
29-
```php
30-
<?php
31-
32-
return [
33-
'disks' => [
34-
//...
35-
'qiniu' => [
36-
'driver' => 'qiniu',
37-
'access_key' => env('QINIU_ACCESS_KEY', 'xxxxxxxxxxxxxxxx'),
38-
'secret_key' => env('QINIU_SECRET_KEY', 'xxxxxxxxxxxxxxxx'),
39-
'bucket' => env('QINIU_BUCKET', 'test'),
40-
'domain' => env('QINIU_DOMAIN', 'xxx.clouddn.com'), // or host: https://xxxx.clouddn.com
41-
],
42-
//...
43-
]
44-
];
45-
```
29+
30+
```php
31+
<?php
32+
33+
return [
34+
'disks' => [
35+
//...
36+
'qiniu' => [
37+
'driver' => 'qiniu',
38+
'access_key' => env('QINIU_ACCESS_KEY', 'xxxxxxxxxxxxxxxx'),
39+
'secret_key' => env('QINIU_SECRET_KEY', 'xxxxxxxxxxxxxxxx'),
40+
'bucket' => env('QINIU_BUCKET', 'test'),
41+
'domain' => env('QINIU_DOMAIN', 'xxx.clouddn.com'), // or host: https://xxxx.clouddn.com
42+
],
43+
//...
44+
]
45+
];
46+
```
4647

4748
# Usage
4849

@@ -57,7 +58,6 @@ $exists = $disk->has('file.jpg');
5758

5859
// get timestamp
5960
$time = $disk->lastModified('file1.jpg');
60-
$time = $disk->getTimestamp('file1.jpg');
6161

6262
// copy a file
6363
$disk->copy('old/file1.jpg', 'new/file1.jpg');
@@ -69,28 +69,27 @@ $disk->move('old/file1.jpg', 'new/file1.jpg');
6969
$contents = $disk->read('folder/my_file.txt');
7070

7171
// fetch url content
72-
$file = $disk->fetch('folder/save_as.txt', $fromUrl);
72+
$file = $disk->getAdapter()->fetch('folder/save_as.txt', $fromUrl);
7373

7474
// get file url
75-
$url = $disk->getUrl('folder/my_file.txt');
75+
$url = $disk->getAdapter()->getUrl('folder/my_file.txt');
7676

7777
// get file upload token
78-
$token = $disk->getUploadToken('folder/my_file.txt');
79-
$token = $disk->getUploadToken('folder/my_file.txt', 3600);
78+
$token = $disk->getAdapter()->getUploadToken('folder/my_file.txt');
79+
$token = $disk->getAdapter()->getUploadToken('folder/my_file.txt', 3600);
8080

8181
// get private url
82-
$url = $disk->privateDownloadUrl('folder/my_file.txt');
82+
$url = $disk->getAdapter()->privateDownloadUrl('folder/my_file.txt');
8383
```
8484

8585
[Full API documentation.](http://flysystem.thephpleague.com/api/)
8686

87-
## :heart: Sponsor me
87+
## :heart: Sponsor me
8888

8989
[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me.svg?raw=true)](https://github.com/sponsors/overtrue)
9090

9191
如果你喜欢我的项目并想支持它,[点击这里 :heart:](https://github.com/sponsors/overtrue)
9292

93-
9493
## Project supported by JetBrains
9594

9695
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

composer.json

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
"name": "overtrue/laravel-filesystem-qiniu",
33
"description": "A Qiniu storage filesystem for Laravel.",
44
"require": {
5-
"php": "^8.0.2",
6-
"league/flysystem": "^3.0",
7-
"overtrue/flysystem-qiniu": "^2.0.0"
5+
"laravel/framework": "^9.0",
6+
"overtrue/flysystem-qiniu": "^3.0"
7+
},
8+
"require-dev": {
9+
"phpunit/phpunit": "^9.5",
10+
"mockery/mockery": "^1.4",
11+
"friendsofphp/php-cs-fixer": "^3.3"
812
},
913
"autoload": {
1014
"psr-4": {
@@ -23,6 +27,35 @@
2327
"providers": [
2428
"Overtrue\\LaravelFilesystem\\Qiniu\\QiniuStorageServiceProvider"
2529
]
30+
},
31+
"hooks": {
32+
"pre-commit": [
33+
"composer test",
34+
"composer check-style"
35+
],
36+
"pre-push": [
37+
"composer test",
38+
"composer check-style"
39+
]
2640
}
41+
},
42+
"scripts": {
43+
"post-update-cmd": [
44+
"cghooks update"
45+
],
46+
"post-merge": "composer install",
47+
"post-install-cmd": [
48+
"cghooks add --ignore-lock",
49+
"cghooks update"
50+
],
51+
"cghooks": "vendor/bin/cghooks",
52+
"check-style": "php-cs-fixer fix --using-cache=no --diff --dry-run --ansi",
53+
"fix-style": "php-cs-fixer fix --using-cache=no --ansi",
54+
"test": "vendor/bin/phpunit"
55+
},
56+
"scripts-descriptions": {
57+
"test": "Run all tests.",
58+
"check-style": "Run style checks (only dry run - no fixing!).",
59+
"fix-style": "Run style checks and fix violations."
2760
}
2861
}
Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,24 @@
11
<?php
22

3-
/*
4-
* This file is part of the overtrue/laravel-filesystem-qiniu.
5-
* (c) overtrue <[email protected]>
6-
* This source file is subject to the MIT license that is bundled
7-
* with this source code in the file LICENSE.
8-
*/
9-
103
namespace Overtrue\LaravelFilesystem\Qiniu;
114

125
use Illuminate\Support\ServiceProvider;
136
use League\Flysystem\Config;
147
use League\Flysystem\Filesystem;
15-
use Overtrue\Flysystem\Qiniu\Plugins\FetchFile;
16-
use Overtrue\Flysystem\Qiniu\Plugins\FileUrl;
17-
use Overtrue\Flysystem\Qiniu\Plugins\PrivateDownloadUrl;
18-
use Overtrue\Flysystem\Qiniu\Plugins\RefreshFile;
19-
use Overtrue\Flysystem\Qiniu\Plugins\UploadToken;
20-
use Overtrue\Flysystem\Qiniu\QiniuAdapter;
218

229
class QiniuStorageServiceProvider extends ServiceProvider
2310
{
24-
/**
25-
* Bootstrap any application services.
26-
*/
2711
public function boot()
2812
{
29-
app('filesystem')->extend('qiniu', function ($app, $config) {
13+
app('filesystem')->extend('qiniu', function ($config) {
3014
$adapter = new QiniuAdapter(
31-
$config['access_key'], $config['secret_key'],
32-
$config['bucket'], $config['domain']
15+
$config['access_key'],
16+
$config['secret_key'],
17+
$config['bucket'],
18+
$config['domain']
3319
);
3420

35-
$flysystem = new Filesystem($adapter, new Config(['disable_asserts' => true]));
36-
37-
$flysystem->addPlugin(new FetchFile());
38-
$flysystem->addPlugin(new UploadToken());
39-
$flysystem->addPlugin(new FileUrl());
40-
$flysystem->addPlugin(new PrivateDownloadUrl());
41-
$flysystem->addPlugin(new RefreshFile());
42-
43-
return $flysystem;
21+
return new Filesystem($adapter, new Config(['disable_asserts' => true]));
4422
});
4523
}
46-
47-
/**
48-
* Register any application services.
49-
*/
50-
public function register()
51-
{
52-
}
5324
}

0 commit comments

Comments
 (0)