PHPackages                             swap-cloud/filesystem - 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. swap-cloud/filesystem

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

swap-cloud/filesystem
=====================

支持 本地 OSS COS 七牛云，文件上传、线上预览、程序调用、等功能。

03PHP

Since Apr 7Pushed 2mo agoCompare

[ Source](https://github.com/swap-cloud/filesystem)[ Packagist](https://packagist.org/packages/swap-cloud/filesystem)[ RSS](/packages/swap-cloud-filesystem/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

文件存储、上传扩展
=========

[](#文件存储上传扩展)

#### 扩展使用Laravel FileSystem 接口 作为存储底层驱动

[](#扩展使用laravel-filesystem-接口-作为存储底层驱动)

### 1. 表单使用

[](#1-表单使用)

```
return $this->baseForm()->body([
            amis()->HiddenControl('id','ID'),
            SwapCloudImageControl('goods_image','商品主图')->required(), // local为默认存储驱动 也可以配置七牛 或者腾讯OCS 或者阿里云OSS
]);
```

### 2. 富文本 图片、文件、视频 上传

[](#2-富文本-图片文件视频-上传)

```
return $this->baseForm()->body([
            amis()->HiddenControl('id','ID'),
            SwapCloudRichTextControl('content','商品详情')->required(), // local为默认存储驱动 也可以配置七牛 或者腾讯OCS 或者阿里云OSS
            SwapCloudWangEditorControl('content','详细描述')->required(), // local为默认存储驱动 也可以配置七牛 或者腾讯OCS 或者阿里云OSS
]);
```

### 3. 附件上传

[](#3-附件上传)

```
return $this->baseForm()->body([
            amis()->HiddenControl('id','ID'),
            SwapCloudFileControl('content','商品详情')->required(), // local为默认存储驱动 也可以配置七牛 或者腾讯OCS 或者阿里云OSS
]);
```

### 列表展示图片

[](#列表展示图片)

```
$crud = $this->baseCRUD()
            ->filterTogglable(false)
            ->headerToolbar([
				$this->createButton(true),
				...$this->baseHeaderToolBar()
            ])
            ->bulkActions('')
            ->columns([
                // .........
                amis()->TableColumn('goods_image')->type('image')
                // .........
        ]);
```

#### API接口使用上传文件接口 在src/Http/api\_routes.php 内定义上传路由 表单字段为 `file`

[](#api接口使用上传文件接口-在srchttpapi_routesphp-内定义上传路由-表单字段为-file)

```
/**
 * 测试上传接口
 */
Route::any('/api-upload-demo', function () {
    $upload = new SwapCloud\FileSystem\Http\Controllers\UploadController();
    try {
        /**
         * 参数一 类型 image or file
         * 参数二 form 字段 例如默认的 `file`
         */
        [$basePath, $fileName] = $upload->upload('image','file'); // image | file
    } catch (\Throwable $throwable) {
        return response()->json([
            'status' => 400,
            'msg' => '上传失败',
        ]);
    }
    return response()->json(['status' => 200, 'msg' => '上传成功', 'data' => [
        'basePath' => $basePath,
        'fileName' => $fileName
    ]]);
});
```

#### 获取存储器用于删除、查询文件的操作

[](#获取存储器用于删除查询文件的操作)

```
// 写入文件
getStorageFilesystem()->put('demo/test.txt','Hello World');
// 删除文件
getStorageFilesystem()->delete('demo/test.txt');
// 获取配置目录下的文件
getStorageFilesystem()->files();
// 文件是否存在
getStorageFilesystem()->exists('demo/test.txt');
// 指定存储器的名称（默认获取当前开启的存储驱动）
getStorageFilesystem('local')->exists('demo/test.txt');
```

#### OSS直传文件组件

[](#oss直传文件组件)

```
SwapCloudOssFileControl('avatar','头像')->required(),
```

#### 自定义目录 文件 的名称生成规则 默认的设置在存储器

[](#自定义目录-文件-的名称生成规则-默认的设置在存储器)

```
// 可用变量

//    {date}      =>   2024-10-11                              // 年月日
//    {datetime}  =>   2024-10-11 17:19:21                     // 年月日时分秒
//    {time}      =>   1728638496                              // 时间戳
//    {uuid}      =>   a1a65110-1c10-400b-8357-e6774793a5a5    // UUID
//    {type}      =>   image                                   // 文件分类
//    {ext}       =>   jpg                                     // 文件后缀名
//    {hash}      =>   698d51a19d8a121ce581499d7b701668        // 文件hash值
//    {rand(32)}  =>   fnooT7QqvsCSLk3Y8jCo1QBJ12W5CFcC        // 随机字符串

SwapCloudImageControl('avatar','头像','oss','my-file/{type}','{time}.{ext}')->required(),
SwapCloudFileControl('avatar','头像','oss','my-file/{type}','{time}.{ext}')->required(),
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance56

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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/4aa333e293f1a1ac60afd39e0c6f3463404df4d6e2ff11bff698c868826aab18?d=identicon)[itxiao6](/maintainers/itxiao6)

---

Top Contributors

[![itxiao6](https://avatars.githubusercontent.com/u/20547806?v=4)](https://github.com/itxiao6 "itxiao6 (7 commits)")

### Embed Badge

![Health badge](/badges/swap-cloud-filesystem/health.svg)

```
[![Health](https://phpackages.com/badges/swap-cloud-filesystem/health.svg)](https://phpackages.com/packages/swap-cloud-filesystem)
```

PHPackages © 2026

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