Skip to content

Commit

Permalink
Flysystem v3. closed #52
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Feb 14, 2022
1 parent 0970355 commit e433ace
Show file tree
Hide file tree
Showing 14 changed files with 228 additions and 590 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ composer.lock
.subsplit
.php_cs.cache
.phpunit.result.cache
.idea
.idea
.php-cs-fixer.cache
49 changes: 49 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'binary_operator_spaces' => true,
'blank_line_after_opening_tag' => true,
'compact_nullable_typehint' => true,
'declare_equal_normalize' => true,
'lowercase_cast' => true,
'lowercase_static_reference' => true,
'new_with_braces' => true,
'no_blank_lines_after_class_opening' => true,
'no_leading_import_slash' => true,
'no_whitespace_in_blank_line' => true,
'no_unused_imports' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
],
],
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'none',
],
'return_type_declaration' => true,
'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
'single_trait_insert_per_statement' => true,
'ternary_operator_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
'const',
'method',
'property',
],
],
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('vendor')
->in([__DIR__.'/src/', __DIR__.'/tests/'])
)
;
26 changes: 0 additions & 26 deletions .php_cs

This file was deleted.

11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

96 changes: 16 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<h1 align="center">Flysystem Qiniu</h1>
Flysystem Adapter for Qiniu Cloud Storage
---

<p align="center">:floppy_disk: Flysystem adapter for the Qiniu storage.</p>

<p align="center">
<a href="https://travis-ci.org/overtrue/flysystem-qiniu"><img src="https://travis-ci.org/overtrue/flysystem-qiniu.svg?branch=master" alt="Build Status"></a>
<a href="https://packagist.org/packages/overtrue/flysystem-qiniu"><img src="https://poser.pugx.org/overtrue/flysystem-qiniu/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/overtrue/flysystem-qiniu"><img src="https://poser.pugx.org/overtrue/flysystem-qiniu/v/unstable.svg" alt="Latest Unstable Version"></a>
<a href="https://scrutinizer-ci.com/g/overtrue/flysystem-qiniu/?branch=master"><img src="https://scrutinizer-ci.com/g/overtrue/flysystem-qiniu/badges/quality-score.png?b=master" alt="Scrutinizer Code Quality"></a>
<a href="https://scrutinizer-ci.com/g/overtrue/flysystem-qiniu/?branch=master"><img src="https://scrutinizer-ci.com/g/overtrue/flysystem-qiniu/badges/coverage.png?b=master" alt="Code Coverage"></a>
<a href="https://packagist.org/packages/overtrue/flysystem-qiniu"><img src="https://poser.pugx.org/overtrue/flysystem-qiniu/downloads" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/overtrue/flysystem-qiniu"><img src="https://poser.pugx.org/overtrue/flysystem-qiniu/license" alt="License"></a>
</p>
:floppy_disk: Flysystem adapter for the Qiniu cloud storage.

[![Build Status](https://travis-ci.org/overtrue/flysystem-qiniu.svg?branch=master)](https://travis-ci.org/overtrue/flysystem-qiniu)
[![Latest Stable Version](https://poser.pugx.org/overtrue/flysystem-qiniu/v/stable.svg)](https://packagist.org/packages/overtrue/flysystem-qiniu)
[![Latest Unstable Version](https://poser.pugx.org/overtrue/flysystem-qiniu/v/unstable.svg)](https://packagist.org/packages/overtrue/flysystem-qiniu)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/overtrue/flysystem-qiniu/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/overtrue/flysystem-qiniu/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/overtrue/flysystem-qiniu/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/overtrue/flysystem-qiniu/?branch=master)
[![Total Downloads](https://poser.pugx.org/overtrue/flysystem-qiniu/downloads)](https://packagist.org/packages/overtrue/flysystem-qiniu)
[![License](https://poser.pugx.org/overtrue/flysystem-qiniu/license)](https://packagist.org/packages/overtrue/flysystem-qiniu)

# Requirement

- PHP >= 5.5.9
- PHP >= 8.0.2

# Installation

```shell
$ composer require "overtrue/flysystem-qiniu" -vvv
$ composer require "overtrue/flysystem-qiniu"
```

# Usage
Expand All @@ -38,87 +36,25 @@ $domain = 'xxxx.bkt.clouddn.com'; // or with protocol: https://xxxx.bkt.clouddn.
$adapter = new QiniuAdapter($accessKey, $secretKey, $bucket, $domain);

$flysystem = new League\Flysystem\Filesystem($adapter);

```

## API

```php
bool $flysystem->write('file.md', 'contents');

bool $flysystem->write('file.md', 'http://httpbin.org/robots.txt', ['mime' => 'application/redirect302']);

bool $flysystem->writeStream('file.md', fopen('path/to/your/local/file.jpg', 'r'));

bool $flysystem->update('file.md', 'new contents');

bool $flysystem->updateStream('file.md', fopen('path/to/your/local/file.jpg', 'r'));

bool $flysystem->rename('foo.md', 'bar.md');

bool $flysystem->copy('foo.md', 'foo2.md');

bool $flysystem->delete('file.md');

bool $flysystem->has('file.md');

bool $flysystem->fileExists('file.md');
bool $flysystem->directoryExists('path/to/dir');
string|false $flysystem->read('file.md');

array $flysystem->listContents();

array $flysystem->getMetadata('file.md');

int $flysystem->getSize('file.md');

int $flysystem->fileSize('file.md');
string $flysystem->getAdapter()->getUrl('file.md');

string $flysystem->getMimetype('file.md');

int $flysystem->getTimestamp('file.md');

```

### Plugins

File Url:

```php
use Overtrue\Flysystem\Qiniu\Plugins\FileUrl;

$flysystem->addPlugin(new FileUrl());

string $flysystem->getUrl('file.md');
```

Fetch file:

```php
use Overtrue\Flysystem\Qiniu\Plugins\FetchFile;

$flysystem->addPlugin(new FetchFile());

bool $flysystem->fetch('file.md', 'http://httpbin.org/robots.txt');
```

Upload Token:

```php
use Overtrue\Flysystem\Qiniu\Plugins\UploadToken;
$flysystem->addPlugin(new UploadToken());

string $flysystem->getUploadToken('file.md', 3600);
```



File private download Url:

```php
use Overtrue\Flysystem\Qiniu\Plugins\PrivateDownloadUrl;

$flysystem->addPlugin(new PrivateDownloadUrl());

string $flysystem->privateDownloadUrl('file.md');
string $flysystem->mimeType('file.md');
```

# Integration
Expand Down
40 changes: 35 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
"name": "overtrue/flysystem-qiniu",
"description": "Flysystem adapter for the Qiniu storage.",
"require": {
"php": ">=7.2",
"league/flysystem": "^2.0",
"league/flysystem": "^3.0",
"qiniu/php-sdk": "^7.2"
},
"require-dev": {
"phpunit/phpunit": "~8.0",
"mockery/mockery": "^1.0"
"phpunit/phpunit": "^9.5",
"mockery/mockery": "^1.4"
},
"autoload": {
"psr-4": {
Expand All @@ -26,5 +25,36 @@
"email": "[email protected]"
}
],
"license": "MIT"
"license": "MIT",
"extra": {
"hooks": {
"pre-commit": [
"composer test",
"composer check-style"
],
"pre-push": [
"composer test",
"composer check-style"
]
}
},
"scripts": {
"post-update-cmd": [
"cghooks update"
],
"post-merge": "composer install",
"post-install-cmd": [
"cghooks add --ignore-lock",
"cghooks update"
],
"cghooks": "vendor/bin/cghooks",
"check-style": "php-cs-fixer fix --using-cache=no --diff --dry-run --ansi",
"fix-style": "php-cs-fixer fix --using-cache=no --ansi",
"test": "vendor/bin/phpunit"
},
"scripts-descriptions": {
"test": "Run all tests.",
"check-style": "Run style checks (only dry run - no fixing!).",
"fix-style": "Run style checks and fix violations."
}
}
25 changes: 0 additions & 25 deletions src/Plugins/FetchFile.php

This file was deleted.

25 changes: 0 additions & 25 deletions src/Plugins/FileUrl.php

This file was deleted.

18 changes: 0 additions & 18 deletions src/Plugins/PrivateDownloadUrl.php

This file was deleted.

18 changes: 0 additions & 18 deletions src/Plugins/RefreshFile.php

This file was deleted.

Loading

0 comments on commit e433ace

Please sign in to comment.