PHPackages                             chunpat/flysystem-tencent-cos - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. chunpat/flysystem-tencent-cos

ActiveLibrary[File &amp; Storage](/categories/file-storage)

chunpat/flysystem-tencent-cos
=============================

Package description here.

0.0.1(5y ago)033MITPHPPHP &gt;=7.1.0CI failing

Since Jun 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/chunpat/flysystem-tencent-cos)[ Packagist](https://packagist.org/packages/chunpat/flysystem-tencent-cos)[ RSS](/packages/chunpat-flysystem-tencent-cos/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (2)Versions (4)Used By (0)

 flysystem-tencent-cos
=======================

[](#-flysystem-tencent-cos-)

 Tencent Cloud Cos Storage adapter for flysystem - a PHP filesystem abstraction.

[![StyleCI build status](https://camo.githubusercontent.com/0dc0a59ace002cf702650d7418db7a3a8ecaef9d2ad0a3c971f1bd837f282b56/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3237343139383337352f736869656c64)](https://camo.githubusercontent.com/0dc0a59ace002cf702650d7418db7a3a8ecaef9d2ad0a3c971f1bd837f282b56/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3237343139383337352f736869656c64)[![Total Downloads](https://camo.githubusercontent.com/0e3b84d6eed5328f5f363643c0b261b6b1c3c03cf8a54758932a201e7230c9d0/68747470733a2f2f706f7365722e707567782e6f72672f6368756e7061742f666c7973797374656d2d74656e63656e742d636f732f646f776e6c6f616473)](https://packagist.org/packages/chunpat/flysystem-tencent-cos)[![License](https://camo.githubusercontent.com/afbdf21d20fbe035b47e2b2979447f2cc8dd13b0e609a33cbc639e2bb6581f34/68747470733a2f2f706f7365722e707567782e6f72672f6368756e7061742f666c7973797374656d2d74656e63656e742d636f732f6c6963656e7365)](https://packagist.org/packages/chunpat/flysystem-tencent-cos)

Installing
----------

[](#installing)

```
$ composer require chunpat/flysystem-tencent-cos -vvv
```

Usage
-----

[](#usage)

```
$secretId = "your secretId";
$secretKey = "your secretKey";
$region = "ap-guangzhou"; //set a default bucket region 设置一个默认的存储桶地域
$cosClient = new Qcloud\Cos\Client(
    array(
        'region' => $region,
        'schema' => 'https', //协议头部，默认为http
        'credentials'=> array(
            'secretId'  => $secretId ,
            'secretKey' => $secretKey)));
$bucket = "zzhpeng-1256184324"; //存储桶名称 格式：BucketName-APPID
$key = "exampleobject"; //filename or path

$adapter = new \Chunpat\FlysystemTencentCos\Adapter($cosClient,$bucket);

try {
    $srcPath = "/Users/zzhpeng/Documents/WechatIMG8.jpeg";//本地文件绝对路径
    $file = fopen($srcPath, "rb");
    $filesystem = new \League\Flysystem\Filesystem($adapter);

    // 设置属性
    // 如设置了Content-Type，则可以不指定路径的后缀 (即$filePath可以不包含.jpg等后缀名)
    $fInfo = new finfo(FILEINFO_MIME_TYPE);
    $mimeType = $fInfo->buffer($srcPath);
    $config = [
        "Content-Type" => $mimeType
    ];
//  $filePath = "test";
    $filePath = "niubi/6666666";

// 上传
//    $filesystem->write($filePath, $file , $config);
//    var_dump($adapter->getResult());

// 更新
//    $filesystem->update($filePath, $file , $config);
//    var_dump($adapter->getResult());

// 删除
//    $filesystem->delete($filePath);
//    var_dump($adapter->getResult());

// 检测是否存在
//    var_dump($filesystem->has($filePath));
//    var_dump($adapter->getResult());

// 读取文件信息
//    $result = $filesystem->read($filePath);
//    var_dump( $result);

//获取文件的权限
//    $result = $filesystem->getVisibility($filePath);
//    var_dump( $result);

//设置文件的权限
//    $visibility = 'public';
//    $result = $filesystem->getVisibility($filePath,$visibility);
//    var_dump( $result);

//复制
//    $newfilePath = "niubi/232132";
//    $result = $filesystem->copy($filePath,$newfilePath);
//    var_dump( $result);

//重命名
//    $newfilePath = "niubi/6666666";
//    $result = $filesystem->rename($filePath,$newfilePath);
//    var_dump( $result);

//创建目录
//    $newfilePath = "niubi2";
//    $result = $filesystem->createDir($newfilePath,$config);
//    var_dump($adapter->getResult());

//删除目录
//    $filePath = "niubi/6666666";
//    $result = $filesystem->deleteDir($filePath);
//    var_dump($result);
//    var_dump($adapter->getResult());

//获取资源信息
//    $filePath = "1111111";
//    $result = $filesystem->getMetadata($filePath);
//    var_dump($result);
//    var_dump($adapter->getResult());

//获取列表
//    $filePath = "";
//    $result = $filesystem->listContents($filePath);
//    var_dump($result);

//用流读
//    $filePath = "23333333";
//    $sourcefile = fopen($srcPath, 'rb');
//    $result = $filesystem->readStream($filePath);

//用流写
//    $filePath = "23333333";
//    $sourcefile = fopen($srcPath, 'rb');
//    $result = $filesystem->readStream($filePath,$file);

//用流更新
//    $filePath = "23333333";
//    $sourcefile = fopen($srcPath, 'rb');
//    $result = $filesystem->updateStream($filePath,$file);

    exit;
} catch (\Exception $e) {
    echo "$e\n";
}
```

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/chunpat/flysystem-tencent-cos/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/chunpat/flysystem-tencent-cos/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

Document
--------

[](#document)

- 1、
- 2、

Reference
---------

[](#reference)

- 1、
- 2、

License
-------

[](#license)

MIT

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2149d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/943b84c2a584d69c0a4b199201be35fd0d8635ef5dcc3bf2d8275dcb6d6e03f0?d=identicon)[zzhpeng](/maintainers/zzhpeng)

---

Top Contributors

[![chunpat](https://avatars.githubusercontent.com/u/19848304?v=4)](https://github.com/chunpat "chunpat (9 commits)")

---

Tags

flysystemflysystem-adaptertencent-cos

### Embed Badge

![Health badge](/badges/chunpat-flysystem-tencent-cos/health.svg)

```
[![Health](https://phpackages.com/badges/chunpat-flysystem-tencent-cos/health.svg)](https://phpackages.com/packages/chunpat-flysystem-tencent-cos)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[yii2-starter-kit/yii2-file-kit

Yii2 file upload and storage kit

151216.8k6](/packages/yii2-starter-kit-yii2-file-kit)[azure-oss/storage-blob-flysystem

Flysystem adapter for Azure Storage PHP

29936.0k10](/packages/azure-oss-storage-blob-flysystem)[jerodev/flysystem-v3-smb-adapter

SMB adapter for Flysystem v3

1289.9k1](/packages/jerodev-flysystem-v3-smb-adapter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
