2017 © Pedro Peláez
 

library flysystem-qcloud-cos-v4

Flysystem Adapter for Tencent Qcloud COS SDK V4

image

freyo/flysystem-qcloud-cos-v4

Flysystem Adapter for Tencent Qcloud COS SDK V4

  • Friday, July 27, 2018
  • by freyo
  • Repository
  • 3 Watchers
  • 14 Stars
  • 320 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 20 Versions
  • 7 % Grown

The README.md

flysystem-qcloud-cos-v4

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

, (*2)

This is a Flysystem adapter for the qcloud-cos-sdk-php v4., (*3)

腾讯云COS对象存储 V4, (*4)

Attention

if you are a new registered user(after October 2016), v4 should be used., (*5)

2016年10月以后新注册的用户默认使用V4版本, (*6)

if you have used COS before October 2016, v3 can continue to use., (*7)

2016年10月之前使用COS的用户可以继续使用V3版本, (*8)

Installation

shell composer require freyo/flysystem-qcloud-cos-v4, (*9)

Bootstrap

```php <?php use Freyo\Flysystem\QcloudCOSv4\Adapter; use League\Flysystem\Filesystem;, (*10)

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

$config = [ 'protocol' => 'http', 'domain' => 'your-domain', 'app_id' => 'your-app-id', 'secret_id' => 'your-secret-id', 'secret_key' => 'your-secret-key', 'timeout' => 60, 'bucket' => 'your-bucket-name', 'region' => 'gz', 'debug' => false, ];, (*12)

$adapter = new Adapter($config); $filesystem = new Filesystem($adapter); ```, (*13)

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'

Full API documentation., (*14)

Use in Laravel

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

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

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

    'disks'=>[
      // ...
      'cosv4' => [
          'driver' => 'cosv4',
          'protocol' => env('COSV4_PROTOCOL', 'http'),
          'domain' => env('COSV4_DOMAIN'),
          'app_id' => env('COSV4_APP_ID'),
          'secret_id' => env('COSV4_SECRET_ID'),
          'secret_key' => env('COSV4_SECRET_KEY'),
          'timeout' => env('COSV4_TIMEOUT', 60),
          'bucket' => env('COSV4_BUCKET'),
          'region' => env('COSV4_REGION', 'gz'),
          'debug' => env('COSV4_DEBUG', false),
      ],
    ],
    

Use in Lumen

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

    $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:, (*19)

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

    COSV4_PROTOCOL=http
    COSV4_DOMAIN=
    COSV4_APP_ID=
    COSV4_SECRET_ID=
    COSV4_SECRET_KEY=
    COSV4_TIMEOUT=60
    COSV4_BUCKET=
    COSV4_REGION=gz
    COSV4_DEBUG=true
    

Usage

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

// 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 support)
$disk->putRemoteFile('avatars/1', 'http://example.org/avatar.jpg');
$disk->putRemoteFileAs('avatars/1', 'http://example.org/avatar.jpg', 'file1.jpg');

Full API documentation., (*21)

Region

地区 区域表示
华南 gz
华北 tj
华东 sh

The Versions

27/07 2018

dev-master

9999999-dev

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

27/07 2018

2.1.1

2.1.1.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

27/07 2018

dev-analysis-qgVLZE

dev-analysis-qgVLZE

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

03/04 2018

2.1.0

2.1.0.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

09/12 2017

2.0.0

2.0.0.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

14/09 2017

dev-official-sdk

dev-official-sdk

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

14/09 2017

dev-analysis-q1nl2N

dev-analysis-q1nl2N

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

13/09 2017

1.4.0

1.4.0.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

11/08 2017

1.3.0

1.3.0.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

09/08 2017

1.2.2

1.2.2.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

11/06 2017

1.2.1

1.2.1.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

05/06 2017

1.2.0

1.2.0.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

01/06 2017

1.1.3

1.1.3.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

25/04 2017

1.1.2

1.1.2.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

25/04 2017

1.0.x-dev

1.0.9999999.9999999-dev

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

25/04 2017

1.1.1

1.1.1.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

24/04 2017

1.1.0

1.1.0.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

23/04 2017

1.0.2

1.0.2.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

22/04 2017

1.0.1

1.0.1.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk

21/04 2017

1.0

1.0.0.0

Flysystem Adapter for Tencent Qcloud COS SDK V4

  Sources   Download

MIT

The Requires

 

by Avatar freyo

qcloud qcloud-cos flysystem-adapter qcloud-sdk