PHPackages                             guanhui07/uploads - 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. guanhui07/uploads

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

guanhui07/uploads
=================

Oss Uploads

v1.0.2(5y ago)03MITPHPPHP &gt;=5.4.0

Since Jun 17Pushed 1y agoCompare

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

READMEChangelogDependencies (3)Versions (4)Used By (0)

通用文件上传到第三方说明文档
==============

[](#通用文件上传到第三方说明文档)

- oss
- qiniu

### 安装

[](#安装)

```
composer require tinymeng/uploads -vvv

```

> 类库使用的命名空间为`\\tinymeng\\uploads`

### 目录结构

[](#目录结构)

```
.
├── src                              代码源文件目录
│   ├── Connector
│   │   ├── Gateway.php            必须继承的抽象类
│   │   └── GatewayInterface.php   必须实现的接口
│   ├── exception
│   │   └── TinymengException.php
│   ├── Gateways
│   │   ├── Cos.php
│   │   └── Oss.php
│   │   └── Qiniu.php
│   ├── Helper
│   │   ├── FileFunction.php
│   │   ├── MimeType.php
│   │   ├── PathLibrary.php
│   │   └── Str.php                 字符串辅助类
│   └── Upload.php                   抽象实例类
├── composer.json                    composer文件
├── LICENSE                          MIT License
└── README.md                        说明文件

```

###### 开始

[](#开始)

- use Storage

```
use Storage;

```

- 示例代码

```
        $config = [
              'accessKeyId'		=> '',
              'accessKeySecret' 	=> '',
              'endpoint'			=> '',
              'isCName'			=> false,
              'securityToken'		=> null,
              'bucket'            => '',
              'timeout'           => '5184000',
              'connectTimeout'    => '10',
              'transport'     	=> 'http',//如果支持https，请填写https，如果不支持请填写http
              'max_keys'          => 1000,//max-keys用于限定此次返回object的最大数，如果不设定，默认为100，max-keys取值不能大于1000
        ];
        $drive = Upload::oss($config);
        $a = $drive->uploadFile("test6.png", $_FILES['file']['tmp_name'] );//file上传文件

        $image  = "11/22/33/7125_yangxiansen.jpg";
        $image2 = "111.png";
        $image3 = "2.txt";

        $drive = Upload::oss($config);
        $drive->write("test2.txt", "111222",$config);
        $drive->getMetadata($image2);                                                         //判断文件是否存在
        $drive->geturl($image2);                                                              //获得文件的 url
        $drive->has($image2);                                                                 //判断文件是否存在
        $drive->listContents('');                                                             //列出文件列表
        $drive->getSize($image2);                                                             //获得图片大小
        $drive->getMimetype($image2);                                                         //获得图片mime类型
        $drive->getTimestamp($image2);                                                        //获得图片上传时间戳
        $drive->read($image3);                                                                //获得文件信息
        $drive->readStream($image3);                                                          //获得文件信息
        $drive->rename($image3, '4.txt/');                                                    //重命名文件
        $drive->copy('4.txt/', '/txt/5.txt');                                                 //复制文件
        $drive->delete('/txt/5.txt');                                                         //删除文件
        $drive->write("/txt/4.txt", $drive->read("/4.txt");                                //上传文件
        $drive->write("/test2.txt", "111222");                                                //上传文件
        $drive->deleteDir('txt/');                                                            //删除文件夹
        $drive->createDir('test3/');                                                          //创建文件夹
        $handle = fopen('/tmp/email.png', 'r');
        $drive->writeStream("/write/test3.png", $handle);                                  //上传文件(文件流方式)
        $drive->writeStream("/test6.png", $drive->readStream('/write/test3.png') );         //上传文件(文件流方式)

```

> 注意：详细使用，可以参考单元测试里面的代码。

###### 配置信息

[](#配置信息)

```

'qiniu' => [
    'driver'        => 'qiniu',
    'domain'        => '',//你的七牛域名
    'access_key'    => '',//AccessKey
    'secret_key'    => '',//SecretKey
    'bucket'        => '',//Bucket名字
    'transport'     => 'http',//如果支持https，请填写https，如果不支持请填写http
],

'oss'	=> [
    'accessKeyId'		=> '',
    'accessKeySecret' 	=> '',
    'endpoint'			=> '',
    'isCName'			=> false,
    'securityToken'		=> null,
    'bucket'            => '',
    'timeout'           => '5184000',
    'connectTimeout'    => '10',
    'transport'     	=> 'http',//如果支持https，请填写https，如果不支持请填写http
    'max_keys'          => 1000,//max-keys用于限定此次返回object的最大数，如果不设定，默认为100，max-keys取值不能大于1000
],

public Qcloud\Cos\Client upload(string $bucket, string $key, $body, array $options = array());

'cos'	=> [
    'secretId'	=> '',
    'secretKey' => '',
    'bucket'    => '',
    'region' 	=> 'ap-beijing',
    'isCName'			=> false,
    'securityToken'		=> null,
    'timeout'           => '5184000',
    'connectTimeout'    => '10',
    'transport'     	=> 'http',//如果支持https，请填写https，如果不支持请填写http
    'max_keys'          => 1000,//max-keys用于限定此次返回object的最大数，如果不设定，默认为100，max-keys取值不能大于1000
],

```

### 版本修复

[](#版本修复)

2021-03-12 更新以下功能 Tag v1.0.2

```
1.增加oss上传设置元信息

可直接下载的文件
$option = [
    OssClient::OSS_CONTENT_TYPE => 'application/octet-stream',
];
$oss_upload_result = $drive->uploadFile($save_file_path, $upload_path,$option);

```

2020-11-12 更新以下功能 Tag v1.0.1

```
1.修改TinymengException异常类

```

###### 协议

[](#协议)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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 ~317 days

Total

3

Last Release

1889d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3abde3fccf025ce86670101d7cfa0641d2415c9daad93e5f0c9573a2b23ddbda?d=identicon)[guanhui07](/maintainers/guanhui07)

---

Top Contributors

[![majiameng](https://avatars.githubusercontent.com/u/24783993?v=4)](https://github.com/majiameng "majiameng (12 commits)")[![guanhui07](https://avatars.githubusercontent.com/u/5820457?v=4)](https://github.com/guanhui07 "guanhui07 (1 commits)")

---

Tags

tinymengoss-uploads

### Embed Badge

![Health badge](/badges/guanhui07-uploads/health.svg)

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

###  Alternatives

[yangyifan/upload

上传 SDK for Laravel

12422.6k3](/packages/yangyifan-upload)

PHPackages © 2026

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