2017 © Pedro Peláez
 

library flysystem-qcloud-cos-v5

Flysystem Adapter for Tencent Qcloud COS SDK V5

image

freyo/flysystem-qcloud-cos-v5

Flysystem Adapter for Tencent Qcloud COS SDK V5

  • Saturday, July 28, 2018
  • by freyo
  • Repository
  • 1 Watchers
  • 35 Stars
  • 1,863 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 14 Versions
  • 180 % Grown

The README.md

, (*1)

Flysystem Adapter for Tencent Cloud Object Storage, (*2)

Software License Build Status Coverage Status Quality Score Packagist Version Total Downloads , (*3)

FOSSA Status , (*4)

Installation

Support Laravel/Lumen 5.x/6.x/7.x/8.x, (*5)

shell composer require "freyo/flysystem-qcloud-cos-v5:^2.0" -vvv, (*6)

Bootstrap

```php <?php use Freyo\Flysystem\QcloudCOSv5\Adapter; use League\Flysystem\Filesystem; use Qcloud\Cos\Client;, (*7)

include DIR . '/vendor/autoload.php';, (*8)

$config = [ 'region' => 'ap-guangzhou', 'credentials' => [ 'appId' => 'your-app-id', 'secretId' => 'your-secret-id', 'secretKey' => 'your-secret-key', 'token' => null, ], 'timeout' => 60, 'connect_timeout' => 60, 'bucket' => 'your-bucket-name', 'cdn' => '', 'scheme' => 'https', 'read_from_cdn' => false, 'cdn_key' => '', 'encrypt' => false, ];, (*9)

$client = new Client($config); $adapter = new Adapter($client, $config); $filesystem = new Filesystem($adapter); ```, (*10)

API

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

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

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

bool $flysystem->updateStram('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');

string|false $flysystem->read('file.md');

array $flysystem->listContents();

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

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

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

string $flysystem->getTemporaryUrl('file.md', date_create('2018-12-31 18:12:31')); 

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

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

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

bool $flysystem->setVisibility('file.md', 'public'); //or 'private', 'default'

Full API documentation., (*11)

Use in Laravel

Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider., (*12)

  1. Register the service provider in config/app.php:, (*13)

    'providers' => [
    // ...
    Freyo\Flysystem\QcloudCOSv5\ServiceProvider::class,
    ]
    
  2. Configure config/filesystems.php:, (*14)

    'disks'=>[
      // ...
      'cosv5' => [
            'driver' => 'cosv5',
            'region'          => env('COSV5_REGION', 'ap-guangzhou'),
            'credentials'     => [
                'appId'     => env('COSV5_APP_ID'),
                'secretId'  => env('COSV5_SECRET_ID'),
                'secretKey' => env('COSV5_SECRET_KEY'),
                'token'     => env('COSV5_TOKEN'),
            ],
            'timeout'         => env('COSV5_TIMEOUT', 60),
            'connect_timeout' => env('COSV5_CONNECT_TIMEOUT', 60),
            'bucket'          => env('COSV5_BUCKET'),
            'cdn'             => env('COSV5_CDN'),
            'scheme'          => env('COSV5_SCHEME', 'https'),
            'read_from_cdn'   => env('COSV5_READ_FROM_CDN', false),
            'cdn_key'         => env('COSV5_CDN_KEY'),
            'encrypt'         => env('COSV5_ENCRYPT', false),
      ],
    ],
    
  3. Configure .env:, (*15)

    COSV5_APP_ID=
    COSV5_SECRET_ID=
    COSV5_SECRET_KEY=
    COSV5_TOKEN=null
    COSV5_TIMEOUT=60
    COSV5_CONNECT_TIMEOUT=60
    COSV5_BUCKET=
    COSV5_REGION=ap-guangzhou
    COSV5_CDN=
    COSV5_SCHEME=https
    COSV5_READ_FROM_CDN=false
    COSV5_CDN_KEY=
    COSV5_ENCRYPT=false
    

Use in Lumen

  1. Add the following code to your bootstrap/app.php:, (*16)

    $app->singleton('filesystem', function ($app) {
      $app->alias('filesystem', Illuminate\Contracts\Filesystem\Factory::class);
      return $app->loadComponent(
          'filesystems',
          Illuminate\Filesystem\FilesystemServiceProvider::class,
          'filesystem'
      );
    });
    
  2. And this:, (*17)

    $app->register(Freyo\Flysystem\QcloudCOSv5\ServiceProvider::class);
    
  3. Configure .env:, (*18)

    COSV5_APP_ID=
    COSV5_SECRET_ID=
    COSV5_SECRET_KEY=
    COSV5_TOKEN=null
    COSV5_TIMEOUT=60
    COSV5_CONNECT_TIMEOUT=60
    COSV5_BUCKET=
    COSV5_REGION=ap-guangzhou
    COSV5_CDN=
    COSV5_SCHEME=https
    COSV5_READ_FROM_CDN=false
    COSV5_CDN_KEY=
    COSV5_ENCRYPT=false
    

Usage

$disk = Storage::disk('cosv5');

// create a file
$disk->put('avatars/1', $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');

// get url
$url = $disk->url('new/file1.jpg');
$temporaryUrl = $disk->temporaryUrl('new/file1.jpg', Carbon::now()->addMinutes(5));

// create a file from remote(plugin)
$disk->putRemoteFile('avatars/1', 'http://example.org/avatar.jpg');
$disk->putRemoteFileAs('avatars/1', 'http://example.org/avatar.jpg', 'file1.jpg');

// refresh cdn cache(plugin)
$disk->cdn()->refreshUrl(['http://your-cdn-host/path/to/avatar.jpg']);
$disk->cdn()->refreshDir(['http://your-cdn-host/path/to/']);
$disk->cdn()->pushUrl(['http://your-cdn-host/path/to/avatar.jpg']);
$disk->cdn()->refreshOverseaUrl(['http://your-cdn-host/path/to/avatar.jpg']);
$disk->cdn()->refreshOverseaDir(['http://your-cdn-host/path/to/']);
$disk->cdn()->pushOverseaUrl(['http://your-cdn-host/path/to/avatar.jpg']);

// cdn url signature(plugin)
$url = 'http://www.test.com/1.mp4';
$disk->cdn()->signatureA($url, $key = null, $timestamp = null, $random = null, $signName = 'sign');
$disk->cdn()->signatureB($url, $key = null, $timestamp = null);
$disk->cdn()->signatureC($url, $key = null, $timestamp = null);
$disk->cdn()->signatureD($url, $key = null, $timestamp = null, $signName = 'sign', $timeName = 't');

// tencent captcha(plugin)
$disk->tcaptcha($aid, $appSecretKey)->verify($ticket, $randStr, $userIP);

// get federation token(plugin)
$disk->getFederationToken($path = '*', $seconds = 7200, Closure $customPolicy = null, $name = 'cos')
$disk->getFederationTokenV3($path = '*', $seconds = 7200, Closure $customPolicy = null, $name = 'cos')

// tencent image process(plugin)
$disk->cloudInfinite()->imageProcess($objectKey, array $picOperations);
$disk->cloudInfinite()->contentRecognition($objectKey, array $contentRecognition);

Full API documentation., (*19)

Regions & Endpoints

Official Documentation, (*20)

License

The MIT License (MIT). Please see License File for more information., (*21)

FOSSA Status, (*22)

The Versions

28/07 2018

dev-master

9999999-dev

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

15/07 2018

1.1.7

1.1.7.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

14/07 2018

1.1.6

1.1.6.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

26/06 2018

1.1.5

1.1.5.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

09/06 2018

1.1.4.1

1.1.4.1

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

09/06 2018

1.1.4

1.1.4.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

07/06 2018

1.1.3

1.1.3.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

02/05 2018

1.1.2

1.1.2.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

28/04 2018

1.1.1

1.1.1.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

09/04 2018

1.1.0

1.1.0.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

06/02 2018

1.0.1

1.0.1.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

06/02 2018

dev-analysis-qgNYL5

dev-analysis-qgNYL5

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

03/02 2018

1.0.0

1.0.0.0

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

10/12 2017

dev-analysis-8nlNRy

dev-analysis-8nlNRy

Flysystem Adapter for Tencent Qcloud COS SDK V5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk