Git Product home page Git Product logo

flysystem-qcloud-cos-v3's Introduction

flysystem-qcloud-cos-v3

Software License Build Status Coverage Status Quality Score Packagist Version Total Downloads

This is a Flysystem adapter for the qcloud-cos-sdk-php v3.

腾讯云COS对象存储 V3

Attention

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

2016年10月以后新注册的用户默认使用V4版本

if you have used COS before October 2016, v3 can continue to use.

2016年10月之前使用COS的用户可以继续使用V3版本

Installation

composer require freyo/flysystem-qcloud-cos-v3

Bootstrap

<?php
use Freyo\Flysystem\QcloudCOSv3\Adapter;
use League\Flysystem\Filesystem;

include __DIR__ . '/vendor/autoload.php';

$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',
    'debug' => false,
];

$adapter = new Adapter($config);
$filesystem = new Filesystem($adapter);

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->getMimetype('file.md');

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

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

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

Full API documentation.

Use in Laravel

  1. Register config/app.php:
Freyo\Flysystem\QcloudCOSv3\ServiceProvider::class,
  1. Configure config/filesystems.php:
'disks'=>[
    'cosv3' => [
        'driver' => 'cosv3',
        'protocol' => env('COSV3_PROTOCOL', 'http'),
        'domain' => env('COSV3_DOMAIN'),
        'app_id' => env('COSV3_APP_ID'),
        'secret_id' => env('COSV3_SECRET_ID'),
        'secret_key' => env('COSV3_SECRET_KEY'),
        'timeout' => env('COSV3_TIMEOUT', 60),
        'bucket' => env('COSV3_BUCKET'),
        'debug' => env('COSV3_DEBUG', false),
    ],
],

Usage

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

// 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');

// 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.

flysystem-qcloud-cos-v3's People

Contributors

freyo avatar scrutinizer-auto-fixer avatar takashiki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tinpont takashiki

flysystem-qcloud-cos-v3's Issues

建议将README中的dev-master去掉

目前你已经发布1.0版本了,可以将README中的dev-master去掉了。

PS:兄弟,找了一圈的COS第三方库(官方的我就不多说了),就你的符合人类使用习惯,感谢了,如果需要协助,随时@我。

建议:修改一下项目名

目前我是fork了一份自己改,因为我发现你的名字里面带有版本号,不好直接提交pull request。我建议通过branch的方式来区分v3还是v4版本,然后在README里面标明如果像用V3请require "~1.0"版本,这样子就可以并行开发。

名字要改的话,adapter最好不要用,感觉没啥意义。我见过众多Laravel Storage扩展库都是直接以flysystem开头的。

建议叫 flysystem-cos或者flysystem-qcloud-cos,这样子一来很清晰你这个项目是跟flysystem兼容的,二来这个东西不止用于laravel可以扩大影响度,laravel支持可以在README里面表明,这样也有利于别人搜索进来。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.