PHPackages                             zerozh/upyun - 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. zerozh/upyun

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

zerozh/upyun
============

又拍云客户端

334PHP

Since Apr 7Pushed 11y ago1 watchersCompare

[ Source](https://github.com/zerozh/upyun)[ Packagist](https://packagist.org/packages/zerozh/upyun)[ RSS](/packages/zerozh-upyun/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Upyun 客户端
=========

[](#upyun-客户端)

安装
--

[](#安装)

Composer 安装：`"zerozh\upyun" : "dev-master"`

本包可能会与其他使用 `\Upyun` Namespace 的包冲突。

使用
--

[](#使用)

请先准备又拍云的操作员帐号，密码，操作空间（Bucket）

### 文件

[](#文件)

```
$client = new \Upyun\Client([
    'username' => 'OPERATOR_USERNAME',
    'password' => 'OPERATOR_PASSWORD',
    'bucket' => 'BUCKET'
]);

// 上传文件
// 可以使用文件资源，本地文件路径或纯文本直接创建文件
// 传入字符串时，若该字符串为有效的本地文件路径，优先使用，否则为文本创建文件
$client->put('somefile.jpg', '/from/local/path/somefile.jpg');
$client->put('another.png', fopen('/from/local/path/another.png', 'r'));
$client->put('also.txt', 'Hello World');

// 获取文件信息
$fileinfo = $client->head('somefile.jpg');
//返回 `\Upyun\Util\FileInfo` 实例，支持的方法如下，参数和返回结果与 SplFileInfo 相同。
echo $fileinfo->getFilename(); // string somefile.jpg
echo $fileinfo->getMTime(); // int UNIX Timestamp
echo $fileinfo->getSize(); // int file size
echo $fileinfo->getType(); // string: file|dir

// 删除文件
$client->delete('somefile.jpg');
```

### 文件夹

[](#文件夹)

```
$client = new \Upyun\Client([
    'username' => 'OPERATOR_USERNAME',
    'password' => 'OPERATOR_PASSWORD',
    'bucket' => 'BUCKET'
]);

// 创建文件夹
$client->mkdir('folder/subfolder');

// 添加一些文件
$client->put('folder/subfolder/1.jpg', '/from/local/path/1.jpg');
$client->put('folder/subfolder/2.jpg', '/from/local/path/2.jpg');
$client->put('folder/subfolder/3.jpg', '/from/local/path/3.jpg');

// 遍历文件夹
$files = $client->ls('folder/subfolder');
foreach($files as $file){
    // 每个文件都为 `\Upyun\Util\FileInfo` 实例
    echo $file->getSize();
    // 如果遇到文件夹，需要手动遍历
    if ($file->isDir()) {
        $files = $client->ls('folder/subfolder/'. $file->getFilename()) . "\n";
    }
}
```

### 递归文件夹（测试）

[](#递归文件夹测试)

```
$client = new \Upyun\Client([
    'username' => 'OPERATOR_USERNAME',
    'password' => 'OPERATOR_PASSWORD',
    'bucket' => 'BUCKET'
]);

// 添加文件
$client->mkdir('folder/subfolder1');
$client->put('folder/subfolder2/json.json', '{"ping":"pong"}');
$client->put('folder/subfolder3.txt', 'Hello World');

// 递归遍历文件夹
$files = $client->ls('folder/subfolder', true);
foreach($files as $file){
    if ($file->isDir()) {
        foreach($file as $subfile){
            echo $file->getFilename() . "/" . $subfile->getFilename() . "\n";
        }
    } else {
        echo $file->getFilename() . ' ' . $file->getSize() . "\n";
    }
}

// 删除文件夹（递归删除所有内容）
$client->rmrf('folder');
```

功能
--

[](#功能)

- 暂未支持高级图片上传设置

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/17cd7f68d6a4e24be66f566b4b7f78e8d41606684947cfd313ce7af0861d6803?d=identicon)[zerozh](/maintainers/zerozh)

---

Top Contributors

[![zerozh](https://avatars.githubusercontent.com/u/2779198?v=4)](https://github.com/zerozh "zerozh (11 commits)")

### Embed Badge

![Health badge](/badges/zerozh-upyun/health.svg)

```
[![Health](https://phpackages.com/badges/zerozh-upyun/health.svg)](https://phpackages.com/packages/zerozh-upyun)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15161.6M2.6k](/packages/illuminate-filesystem)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)[madnest/madzipper

Easier zip file handling for Laravel applications.

1382.3M6](/packages/madnest-madzipper)

PHPackages © 2026

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