PHPackages                             tinywan/storage - 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. tinywan/storage

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

tinywan/storage
===============

webman storage plugin

v1.1.2(10mo ago)3520.9k↑407.5%11[5 issues](https://github.com/Tinywan/webman-storage/issues)20MITPHPPHP &gt;=7.2CI failing

Since Mar 12Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/Tinywan/webman-storage)[ Packagist](https://packagist.org/packages/tinywan/storage)[ RSS](/packages/tinywan-storage/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (9)Versions (18)Used By (20)

webman 简单易用多文件上传插件
==================

[](#webman-简单易用多文件上传插件)

[![Latest Stable Version](https://camo.githubusercontent.com/60a3199bd18a590621b11a9821f9a5a0480b547724c5d13a1fc5e38178c8851b/687474703a2f2f706f7365722e707567782e6f72672f74696e7977616e2f73746f726167652f76)](https://packagist.org/packages/tinywan/storage) [![Total Downloads](https://camo.githubusercontent.com/6db8441b5810f5be63f028d70535b1560cda899055f70d50e929623d7f82370f/687474703a2f2f706f7365722e707567782e6f72672f74696e7977616e2f73746f726167652f646f776e6c6f616473)](https://packagist.org/packages/tinywan/storage)[![Daily Downloads](https://camo.githubusercontent.com/3b3d38b072e56ccbfa2d75dfbfd73e63b3ee37ba821aa0add60772a8ece79c45/687474703a2f2f706f7365722e707567782e6f72672f74696e7977616e2f73746f726167652f642f6461696c79)](https://packagist.org/packages/tinywan/storage)[![Latest Unstable Version](https://camo.githubusercontent.com/a4c307f606bf25108fdf657150ef0bbe85ac26e8716baff118cdc1f0ea595b01/687474703a2f2f706f7365722e707567782e6f72672f74696e7977616e2f73746f726167652f762f756e737461626c65)](https://packagist.org/packages/tinywan/storage)[![License](https://camo.githubusercontent.com/94a922447bbfc71bc06db5f49b115345a8df4cf8b78c4ab4f8902f49185f0fc9/687474703a2f2f706f7365722e707567782e6f72672f74696e7977616e2f73746f726167652f6c6963656e7365)](https://packagist.org/packages/tinywan/storage)[![PHP Version Require](https://camo.githubusercontent.com/ebbca74c4261cd8a04bb291366c79ce6afc70a30c71169e8dd8af1a10a784d80/687474703a2f2f706f7365722e707567782e6f72672f74696e7977616e2f73746f726167652f726571756972652f706870)](https://packagist.org/packages/tinywan/storage)![last-commit](https://camo.githubusercontent.com/0b7e033bec1e439af7f3fae0a250119c48561b2616670477989f3f14c2a777d6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f74696e7977616e2f73746f726167652f6d61696e)![storage tag](https://camo.githubusercontent.com/07d5982c92d55ff8b723fc3489a4c974a430f07cf9ef4748f32ff083fd33d38d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f74696e7977616e2f73746f726167653f636f6c6f723d666636396234)

特性
--

[](#特性)

云端多文件上传Base64图片上传服务器文件上传🍏 私有云✅--✅🍓 阿里云✅✅✅🍋 腾讯云✅✅✅🍇 七牛云✅✅✅🍇 亚马逊（S3）✅✅✅安装
--

[](#安装)

```
composer require tinywan/storage
```

基本用法
----

[](#基本用法)

```
$res = Tinywan\Storage\Storage::uploadFile();
var_dump(json_encode($res));
```

> `v1.0.0` 版本之后不需要调用此方法`Tinywan\Storage\Storage::config()` 初始化，会自动初始化，默认为配置文件`app.php`默认配置`default`配置上传适配器。

### 上传成功信息

[](#上传成功信息)

```
[
    {
        "key": "webman",
        "origin_name": "常用编程软件和工具.xlsx",
        "save_name": "03414c9bdaf7a38148742c87b96b8167.xlsx",
        "save_path": "runtime/storage/03414c9bdaf7a38148742c87b96b8167.xlsx",
        "save_path": "/var/www/webman-admin/public/storage/03414c9bdaf7a38148742c87b96b8167.xlsx",
        "url": "/storage/fd2d472da56c71a6da0a5251f5e1b586.png",
        "uniqid ": "03414c9bdaf7a38148742c87b96b8167",
        "size": 15050,
        "mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
        "extension": "xlsx"
    }
    ...
]
```

> 失败，抛出`StorageAdapterException`异常

### 成功响应字段

[](#成功响应字段)

字段描述示例值key上传文件keywebmanorigin\_name原始文件名常用编程软件和工具.xlsxsave\_name保存文件名03414c9bdaf7a38148742c87b96b8167.xlsxsave\_path文件保存路径（相对）/var/www/webman-admin/runtime/storage/03414c9bdaf7a38148742c87b96b8167.xlsxurlurl访问路径/storage/03414c9bdaf7a38148742c87b96b8167.xlsxunique\_iduniqid03414c9bdaf7a38148742c87b96b8167size文件大小15050（字节）mime\_type文件类型application/vnd.openxmlformats-officedocument.spreadsheetml.sheetextension文件扩展名xlsx上传规则
----

[](#上传规则)

默认情况下是上传到本地服务器，会在`runtime/storage`目录下面生成以当前日期为子目录，以文件流的sha1编码为文件名的文件，例如上面生成的文件名可能是：

```
runtime/storage/fd2d472da56c71a6da0a5251f5e1b586.png

```

如果你希望上传的文件是可以直接访问或者下载的话，可以使用`public`存储方式。

你可以在`config/plugin/tinywan/storage/app.php`配置文件中配置上传根目录，例如：

```
'local' => [
    'adapter' => \Tinywan\Storage\Adapter\LocalAdapter::class,
    'root' => public_path() . '/storage',
],
```

> 浏览器访问：

上传验证
----

[](#上传验证)

支持使用验证类对上传文件的验证，包括文件大小、文件类型和后缀

字段描述示例值single\_limit单个文件的大小限制，默认200M1024 \* 1024 \* 200total\_limit所有文件的大小限制，默认200M1024 \* 1024 \* 200nums文件数量限制，默认1010include被允许的文件类型列表\['xlsx','pdf'\]exclude不被允许的文件类型列表\['png','jpg'\]支持上传SDK
-------

[](#支持上传sdk)

#### 阿里云对象存储

[](#阿里云对象存储)

```
composer require aliyuncs/oss-sdk-php
```

#### 腾讯云对象存储

[](#腾讯云对象存储)

```
composer require qcloud/cos-sdk-v5
```

#### 七牛云云对象存储

[](#七牛云云对象存储)

```
composer require qiniu/php-sdk
```

#### 亚马逊（S3）对象存储

[](#亚马逊s3对象存储)

```
composer require league/flysystem-aws-s3-v3
```

上传Base64图片
----------

[](#上传base64图片)

> **使用场景：** 前端直接截图（头像、Canvas等）一个Base64数据流的图片直接上传到云端

#### 请求参数

[](#请求参数)

```
{
    "extension": "png",
    "base64": "data:image/jpeg;base64,/9j/4AAQSkxxxxxxxxxxxxZJRgABvtyQBIr/MPTPTP/2Q=="
}
```

#### 请求案例（阿里云）

[](#请求案例阿里云)

```
public function upload(Request $request)
{
    $base64 = $request->post('base64');
    $response = \Tinywan\Storage\Storage::disk(\Tinywan\Storage\Storage::MODE_OSS, false)->uploadBase64($base64,'png');
    var_dump($response);
}
```

> `v1.0.0` 版本之后不需要调用此方法`Tinywan\Storage\Storage::config()` 初始化，会自动初始化，默认为配置文件`app.php`默认配置`default`配置上传适配器。

#### 响应参数

[](#响应参数)

```
{
	"save_path": "storage/20220402213639624851671439e.png",
	"url": "http://webman.oss.tinywan.com/storage/20220402213639624851671439e.png",
	"unique_id": "20220402213639624851671439e",
	"size": 11802,
	"extension": "png"
}
```

上传服务端文件
-------

[](#上传服务端文件)

> **使用场景：** 服务端导出文件需要上传到云端存储，或者零时下载文件存储。

#### 请求案例（阿里云）

[](#请求案例阿里云-1)

```
$serverFile = runtime_path() . DIRECTORY_SEPARATOR . 'storage/webman.png';
$res = \Tinywan\Storage\Storage::disk(\Tinywan\Storage\Storage::MODE_OSS, false)->uploadServerFile($serverFile);
```

> `v1.0.0` 版本之后不需要调用此方法`Tinywan\Storage\Storage::config()` 初始化，会自动初始化，默认为配置文件`app.php`默认配置`default`配置上传适配器。

#### 响应参数

[](#响应参数-1)

```
{
	"origin_name": "/var/www/webman-admin/runtime/storage/webman.png",
	"save_path": "storage/6edf04d7c26f020cf5e46e6457620220402213414.png",
	"url": "http://webman.oss.tinywan.com/storage/6ed9ffd54d0df57620220402213414.png",
	"unique_id": "6edf04d7c26f020cf5e46e6403213414",
	"size": 3505604,
	"extension": "png"
}
```

Other
-----

[](#other)

### phpstan

[](#phpstan)

```
vendor/bin/phpstan analyse src

vendor/bin/php-cs-fixer fix src

```

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance52

Moderate activity, may be stable

Popularity40

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.9% 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

Every ~78 days

Recently: every ~278 days

Total

17

Last Release

306d ago

Major Versions

v0.3.4 → v1.0.02024-01-13

PHP version history (2 changes)v0.0.1PHP &gt;=7.2

v0.0.5PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b0042e0b68ff6a731ef382a03eecd211736c2d619acc55b2b326988085f72bfb?d=identicon)[Tinywan](/maintainers/Tinywan)

---

Top Contributors

[![Tinywan](https://avatars.githubusercontent.com/u/14959876?v=4)](https://github.com/Tinywan "Tinywan (58 commits)")[![edwinhuish](https://avatars.githubusercontent.com/u/5207925?v=4)](https://github.com/edwinhuish "edwinhuish (10 commits)")[![GragonAo](https://avatars.githubusercontent.com/u/49135462?v=4)](https://github.com/GragonAo "GragonAo (1 commits)")[![sorshion](https://avatars.githubusercontent.com/u/12489667?v=4)](https://github.com/sorshion "sorshion (1 commits)")

---

Tags

ossphp-librarytinywanuploadupload-filewebmanworkerman

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tinywan-storage/health.svg)

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

PHPackages © 2026

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