{"id":15631853,"url":"https://github.com/freyo/flysystem-qcloud-cos-v4","last_synced_at":"2025-04-30T06:46:38.401Z","repository":{"id":62507433,"uuid":"88835785","full_name":"freyo/flysystem-qcloud-cos-v4","owner":"freyo","description":"💾 Flysystem Adapter for Tencent Qcloud COS SDK V4","archived":false,"fork":false,"pushed_at":"2018-07-27T08:36:34.000Z","size":112,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T06:46:25.704Z","etag":null,"topics":["cos","flysystem-adapter","flysystem-qcloud-cos","laravel","php","qcloud-sdk"],"latest_commit_sha":null,"homepage":"https://www.qcloud.com/product/cos","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/freyo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-20T07:43:42.000Z","updated_at":"2022-09-24T02:00:18.000Z","dependencies_parsed_at":"2022-11-02T12:31:28.802Z","dependency_job_id":null,"html_url":"https://github.com/freyo/flysystem-qcloud-cos-v4","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freyo%2Fflysystem-qcloud-cos-v4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freyo%2Fflysystem-qcloud-cos-v4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freyo%2Fflysystem-qcloud-cos-v4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freyo%2Fflysystem-qcloud-cos-v4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freyo","download_url":"https://codeload.github.com/freyo/flysystem-qcloud-cos-v4/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251658196,"owners_count":21622819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cos","flysystem-adapter","flysystem-qcloud-cos","laravel","php","qcloud-sdk"],"created_at":"2024-10-03T10:41:48.081Z","updated_at":"2025-04-30T06:46:38.316Z","avatar_url":"https://github.com/freyo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flysystem-qcloud-cos-v4\n\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Build Status](https://img.shields.io/travis/freyo/flysystem-qcloud-cos-v4/master.svg?style=flat-square)](https://travis-ci.org/freyo/flysystem-qcloud-cos-v4)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/freyo/flysystem-qcloud-cos-v4.svg?style=flat-square)](https://scrutinizer-ci.com/g/freyo/flysystem-qcloud-cos-v4)\n[![Quality Score](https://img.shields.io/scrutinizer/g/freyo/flysystem-qcloud-cos-v4.svg?style=flat-square)](https://scrutinizer-ci.com/g/freyo/flysystem-qcloud-cos-v4)\n[![Packagist Version](https://img.shields.io/packagist/v/freyo/flysystem-qcloud-cos-v4.svg?style=flat-square)](https://packagist.org/packages/freyo/flysystem-qcloud-cos-v4)\n[![Total Downloads](https://img.shields.io/packagist/dt/freyo/flysystem-qcloud-cos-v4.svg?style=flat-square)](https://packagist.org/packages/freyo/flysystem-qcloud-cos-v4)\n\n\u003cimage src=\"https://mc.qcloudimg.com/static/img/e9ea555bef030eb7b380e9a3a1e59323/COS.svg\" width=\"220\" height=\"220\"\u003e\n\nThis is a Flysystem adapter for the qcloud-cos-sdk-php v4.\n\n腾讯云COS对象存储 V4\n\n## Attention\n\nif you are a new registered user(after October 2016), [v4](https://packagist.org/packages/freyo/flysystem-qcloud-cos-v4) should be used.\n\n2016年10月以后新注册的用户默认使用[V4版本](https://packagist.org/packages/freyo/flysystem-qcloud-cos-v4)\n\nif you have used COS before October 2016, [v3](https://packagist.org/packages/freyo/flysystem-qcloud-cos-v3) can continue to use.\n\n2016年10月之前使用COS的用户可以继续使用[V3版本](https://packagist.org/packages/freyo/flysystem-qcloud-cos-v3)\n\n## Installation\n\n  ```shell\n  composer require freyo/flysystem-qcloud-cos-v4\n  ```\n\n## Bootstrap\n\n  ```php\n  \u003c?php\n  use Freyo\\Flysystem\\QcloudCOSv4\\Adapter;\n  use League\\Flysystem\\Filesystem;\n\n  include __DIR__ . '/vendor/autoload.php';\n\n  $config = [\n      'protocol' =\u003e 'http',\n      'domain' =\u003e 'your-domain',\n      'app_id' =\u003e 'your-app-id',\n      'secret_id' =\u003e 'your-secret-id',\n      'secret_key' =\u003e 'your-secret-key',\n      'timeout' =\u003e 60,\n      'bucket' =\u003e 'your-bucket-name',\n      'region' =\u003e 'gz',\n      'debug' =\u003e false,\n  ];\n\n  $adapter = new Adapter($config);\n  $filesystem = new Filesystem($adapter);\n  ```\n\n### API\n\n```php\nbool $flysystem-\u003ewrite('file.md', 'contents');\n\nbool $flysystem-\u003ewriteStream('file.md', fopen('path/to/your/local/file.jpg', 'r'));\n\nbool $flysystem-\u003eupdate('file.md', 'new contents');\n\nbool $flysystem-\u003eupdateStram('file.md', fopen('path/to/your/local/file.jpg', 'r'));\n\nbool $flysystem-\u003erename('foo.md', 'bar.md');\n\nbool $flysystem-\u003ecopy('foo.md', 'foo2.md');\n\nbool $flysystem-\u003edelete('file.md');\n\nbool $flysystem-\u003ehas('file.md');\n\nstring|false $flysystem-\u003eread('file.md');\n\narray $flysystem-\u003elistContents();\n\narray $flysystem-\u003egetMetadata('file.md');\n\nint $flysystem-\u003egetSize('file.md');\n\nstring $flysystem-\u003egetUrl('file.md'); \n\nstring $flysystem-\u003egetTemporaryUrl('file.md', date_create('2018-12-31 18:12:31')); \n\nstring $flysystem-\u003egetMimetype('file.md');\n\nint $flysystem-\u003egetTimestamp('file.md');\n\nstring $flysystem-\u003egetVisibility('file.md');\n\nbool $flysystem-\u003esetVisibility('file.md', 'public'); //or 'private'\n```\n\n[Full API documentation.](http://flysystem.thephpleague.com/api/)\n\n## Use in Laravel\n  \n**Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.**\n\n1. Register the service provider in `config/app.php`:\n\n  ```php\n  'providers' =\u003e [\n    // ...\n    Freyo\\Flysystem\\QcloudCOSv4\\ServiceProvider::class,\n  ]\n  ```\n\n2. Configure `config/filesystems.php`:\n\n  ```php\n  'disks'=\u003e[\n      // ...\n      'cosv4' =\u003e [\n          'driver' =\u003e 'cosv4',\n          'protocol' =\u003e env('COSV4_PROTOCOL', 'http'),\n          'domain' =\u003e env('COSV4_DOMAIN'),\n          'app_id' =\u003e env('COSV4_APP_ID'),\n          'secret_id' =\u003e env('COSV4_SECRET_ID'),\n          'secret_key' =\u003e env('COSV4_SECRET_KEY'),\n          'timeout' =\u003e env('COSV4_TIMEOUT', 60),\n          'bucket' =\u003e env('COSV4_BUCKET'),\n          'region' =\u003e env('COSV4_REGION', 'gz'),\n          'debug' =\u003e env('COSV4_DEBUG', false),\n      ],\n  ],\n  ```\n\n## Use in Lumen\n\n1. Add the following code to your `bootstrap/app.php`:\n\n  ```php\n  $app-\u003esingleton('filesystem', function ($app) {\n      $app-\u003ealias('filesystem', Illuminate\\Contracts\\Filesystem\\Factory::class);\n      return $app-\u003eloadComponent(\n          'filesystems',\n          Illuminate\\Filesystem\\FilesystemServiceProvider::class,\n          'filesystem'\n      );\n  });\n  ```\n\n2. And this:\n  \n  ```php\n  $app-\u003eregister(Freyo\\Flysystem\\QcloudCOSv4\\ServiceProvider::class);\n  ```\n\n3. Configure `.env`:\n  \n  ```php\n  COSV4_PROTOCOL=http\n  COSV4_DOMAIN=\n  COSV4_APP_ID=\n  COSV4_SECRET_ID=\n  COSV4_SECRET_KEY=\n  COSV4_TIMEOUT=60\n  COSV4_BUCKET=\n  COSV4_REGION=gz\n  COSV4_DEBUG=true\n  ```\n  \n### Usage\n\n```php\n$disk = Storage::disk('cosv4');\n\n// create a file\n$disk-\u003eput('avatars/1', $fileContents);\n\n// check if a file exists\n$exists = $disk-\u003ehas('file.jpg');\n\n// get timestamp\n$time = $disk-\u003elastModified('file1.jpg');\n\n// copy a file\n$disk-\u003ecopy('old/file1.jpg', 'new/file1.jpg');\n\n// move a file\n$disk-\u003emove('old/file1.jpg', 'new/file1.jpg');\n\n// get file contents\n$contents = $disk-\u003eread('folder/my_file.txt');\n\n// get url\n$url = $disk-\u003eurl('new/file1.jpg');\n$temporaryUrl = $disk-\u003etemporaryUrl('new/file1.jpg', Carbon::now()-\u003eaddMinutes(5));\n\n// create a file from remote(plugin support)\n$disk-\u003eputRemoteFile('avatars/1', 'http://example.org/avatar.jpg');\n$disk-\u003eputRemoteFileAs('avatars/1', 'http://example.org/avatar.jpg', 'file1.jpg');\n```\n\n[Full API documentation.](https://laravel.com/api/5.4/Illuminate/Contracts/Filesystem/Cloud.html)\n\n## Region\n\n|地区|区域表示|\n|:-:|:-:|\n|华南|gz|\n|华北|tj|\n|华东|sh|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreyo%2Fflysystem-qcloud-cos-v4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreyo%2Fflysystem-qcloud-cos-v4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreyo%2Fflysystem-qcloud-cos-v4/lists"}