Skip to content

Commit 23c2748

Browse files
committed
🌟 init commit.
0 parents  commit 23c2748

File tree

8 files changed

+199
-0
lines changed

8 files changed

+199
-0
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = false
10+
11+
[*.{vue,js,scss}]
12+
charset = utf-8
13+
indent_style = space
14+
indent_size = 2
15+
end_of_line = lf
16+
insert_final_newline = true
17+
trim_trailing_whitespace = true
18+
19+
[*.md]
20+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto
2+
3+
/tests export-ignore
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
.scrutinizer.yml export-ignore
7+
.travis.yml export-ignore
8+
phpunit.php export-ignore
9+
phpunit.xml.dist export-ignore
10+
phpunit.xml export-ignore
11+
.php_cs export-ignore

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.DS_Store
2+
/vendor
3+
/coverage
4+
sftp-config.json
5+
composer.lock
6+
.subsplit
7+
.php_cs.cache
8+
.idea

.php_cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
$header = <<<EOF
3+
This file is part of the overtrue/laravel-filesystem-qiniu.
4+
(c) overtrue <[email protected]>
5+
This source file is subject to the MIT license that is bundled
6+
with this source code in the file LICENSE.
7+
EOF;
8+
9+
return PhpCsFixer\Config::create()
10+
->setRiskyAllowed(true)
11+
->setRules(array(
12+
'@Symfony' => true,
13+
'header_comment' => array('header' => $header),
14+
'array_syntax' => array('syntax' => 'short'),
15+
'ordered_imports' => true,
16+
'no_useless_else' => true,
17+
'no_useless_return' => true,
18+
'php_unit_construct' => true,
19+
'php_unit_strict' => true,
20+
))
21+
->setFinder(
22+
PhpCsFixer\Finder::create()
23+
->exclude('vendor')
24+
->in(__DIR__)
25+
)
26+
;

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Laravel filesystem Qiniu
2+
3+
[Qiniu](www.qiniu.com) storage for Laravel based on [overtrue/flysystem-qiniu](https://github.com/overtrue/flysystem-qiniu).
4+
5+
# Requirement
6+
7+
- PHP >= 5.5.9
8+
9+
# Installation
10+
11+
```shell
12+
$ composer require "overtrue/laravel-filesystem-qiniu" -vvv
13+
```
14+
15+
# Configuration
16+
17+
1. After installing the library, register the `Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProvider` in your config/app.php configuration file:
18+
19+
```php
20+
'providers' => [
21+
// Other service providers...
22+
Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProvider::class,
23+
],
24+
```
25+
26+
2. Add a new disk to your `config/filesystems.php` config:
27+
```php
28+
<?php
29+
30+
return [
31+
//...
32+
'qiniu' => [
33+
'driver' => 'qiniu',
34+
'access_key' => 'R7XWZeqqwNA76AdKrffHRfWTn6S9S-jYN9N3-Kex',
35+
'secret_key' => 'VMQkEEuErwnav-NJnFRYHagOczdCH3gQ6dWbTrMp',
36+
'bucket' => 'test',
37+
'domain' => 'omstl4zdr.bkt.clouddn.com',
38+
],
39+
//...
40+
];
41+
```
42+
43+
# Usage
44+
45+
```php
46+
$disk = Storage::disk('qiniu');
47+
48+
// create a file
49+
$disk->put('avatars/1', $fileContents);
50+
51+
// check if a file exists
52+
$exists = $disk->has('file.jpg');
53+
54+
// get timestamp
55+
$time = $disk->lastModified('file1.jpg');
56+
$time = $disk->getTimestamp('file1.jpg');
57+
58+
// copy a file
59+
$disk->copy('old/file1.jpg', 'new/file1.jpg');
60+
61+
// move a file
62+
$disk->move('old/file1.jpg', 'new/file1.jpg');
63+
64+
// get file contents
65+
$contnets = $disk->read('folder/my_file.txt');
66+
67+
```
68+
69+
[Full API documentation.](http://flysystem.thephpleague.com/api/)
70+
71+
# License
72+
73+
MIT

composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "overtrue/laravel-filesystem-qiniu",
3+
"description": "A Qiniu storage filesystem for Laravel.",
4+
"require": {
5+
"php": ">=5.5.9",
6+
"league/flysystem": "^1.0",
7+
"overtrue/flysystem-qiniu": "^0.0.1"
8+
},
9+
"autoload": {
10+
"psr-4": {
11+
"Overtrue\\LaravelFilesystem\\Qiniu\\": "src"
12+
}
13+
},
14+
"authors": [
15+
{
16+
"name": "overtrue",
17+
"email": "[email protected]"
18+
}
19+
],
20+
"license": "MIT"
21+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
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+
10+
namespace Overtrue\LaravelFilesystem\Qiniu;
11+
12+
use Illuminate\Support\Facades\Storage;
13+
use Illuminate\Support\ServiceProvider;
14+
use League\Flysystem\Filesystem;
15+
use Overtrue\Flysystem\Qiniu\QiniuAdapter;
16+
17+
class QiniuStorageServiceProvider extends ServiceProvider
18+
{
19+
/**
20+
* Bootstrap any application services.
21+
*/
22+
public function boot()
23+
{
24+
Storage::extend('qiniu', function ($app, $config) {
25+
$adapter = new QiniuAdapter(
26+
$config['access_key'], $config['secret_key'],
27+
$config['bucket'], $config['domain']
28+
);
29+
30+
return new Filesystem($adapter);
31+
});
32+
}
33+
34+
/**
35+
* Register any application services.
36+
*/
37+
public function register()
38+
{
39+
}
40+
}

tests/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)