Download the PHP package tinywan/storage without Composer

On this page you can find all versions of the php package tinywan/storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package storage

# 📦 webman-storage **webman 简单易用多文件上传插件** 本地 / 阿里云 OSS / 腾讯云 COS / 七牛云 / AWS S3 · 统一 API · 开箱即用 [![Latest Stable Version](http://poser.pugx.org/tinywan/storage/v)](https://packagist.org/packages/tinywan/storage) [![Total Downloads](http://poser.pugx.org/tinywan/storage/downloads)](https://packagist.org/packages/tinywan/storage) [![Daily Downloads](http://poser.pugx.org/tinywan/storage/d/daily)](https://packagist.org/packages/tinywan/storage) [![Latest Unstable Version](http://poser.pugx.org/tinywan/storage/v/unstable)](https://packagist.org/packages/tinywan/storage) [![License](http://poser.pugx.org/tinywan/storage/license)](https://packagist.org/packages/tinywan/storage) [![PHP Version Require](http://poser.pugx.org/tinywan/storage/require/php)](https://packagist.org/packages/tinywan/storage) [![last-commit](https://img.shields.io/github/last-commit/tinywan/storage/main)]() [![storage tag](https://img.shields.io/github/v/tag/tinywan/storage?color=ff69b4)]()

📑 目录

✨ 特性

能力矩阵

云端 多文件上传 Base64 图片上传 服务器文件上传 大文件分片上传
🍏 私有云(本地)
🍓 阿里云
🍋 腾讯云
🍇 七牛云
🌰 亚马逊(S3)

🚀 安装

[!NOTE] 要求 PHP >= 7.2workerman/webman-framework ^1.5.4 || ^2.0。 插件安装后自动发布配置到 config/plugin/tinywan/storage/app.php


⚡ 快速开始

[!NOTE] 无需手动初始化,默认使用配置 storage.default 指定的上传适配器。

上传成功信息

[!WARNING] 上传失败时抛出 StorageException 异常。

成功响应字段

字段 描述 示例值
key 上传文件 key webman
origin_name 原始文件名 常用编程软件和工具.xlsx
save_name 保存文件名 03414c9bdaf7a38148742c87b96b8167.xlsx
save_path 文件保存路径 /var/www/webman-admin/runtime/storage/03414c9bdaf7a38148742c87b96b8167.xlsx
url url 访问路径 /storage/03414c9bdaf7a38148742c87b96b8167.xlsx
unique_id 文件散列值 03414c9bdaf7a38148742c87b96b8167
size 文件大小(字节) 15050
mime_type 文件类型 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
extension 文件扩展名 xlsx

📁 上传规则

默认上传到本地服务器,在 runtime/storage 目录下生成以当前日期为子目录、以文件流散列值(algo 配置,默认 sha1)为文件名的文件:

如果希望上传的文件可以直接访问或下载,可以将上传根目录配置到 public 目录。在 config/plugin/tinywan/storage/app.php 中配置:

浏览器访问:http://127.0.0.1:8787/storage/fd2d472da56c71a6da0a5251f5e1b586.png


🛡️ 上传验证

支持对上传文件的大小、数量、类型和后缀进行验证:

字段 描述 示例值
single_limit 单个文件的大小限制,默认 200M 1024 * 1024 * 200
total_limit 所有文件的大小限制,默认 200M 1024 * 1024 * 200
nums 文件数量限制,默认 10 10
include 被允许的文件类型列表(白名单) ['xlsx', 'pdf']
exclude 不被允许的文件类型列表(黑名单) ['png', 'jpg']

☁️ 云端 SDK

按需安装对应云存储 SDK 后,仅需切换 Storage::disk() 参数即可:

云存储 安装命令 磁盘常量
🍓 阿里云 OSS composer require aliyuncs/oss-sdk-php Storage::MODE_OSS
🍋 腾讯云 COS composer require qcloud/cos-sdk-v5 Storage::MODE_COS
🍇 七牛云 composer require qiniu/php-sdk Storage::MODE_QINIU
🌰 亚马逊 S3 composer require league/flysystem-aws-s3-v3 Storage::MODE_S3

🖼️ 上传 Base64 图片

使用场景: 前端直接截图(头像、Canvas 等)生成 Base64 数据流的图片,直接上传到云端。

请求参数

请求示例(阿里云)

响应参数


🗂️ 上传服务端文件

使用场景: 服务端导出的文件需要上传到云端存储,或者临时下载文件存储。

请求示例(阿里云)

响应参数


🧩 大文件分片上传(本地)

使用场景: 大文件(超出 upload_max_filesize 或网络不稳定)由前端切片后逐片上传,服务端校验并合并。目前仅本地适配器支持,云端适配器(OSS/COS/七牛/S3)后续版本支持。

🧪 端到端测试示例见 example/:示例控制器、路由和 curl 一键测试脚本。

工作流程

相关配置

① 上传分片 uploadChunk

响应参数:

[!NOTE] 同一 chunk_index 重复上传会覆盖旧分片(断点续传语义);md5 校验失败会抛出 StorageException 且不落盘。

② 断点续传查询 chunkProgress

响应参数(前端根据 missing 补传缺失分片):

③ 合并分片 mergeChunk

响应参数与普通上传单文件结构一致(origin_name/save_name/save_path/url/unique_id/size/mime_type/extension),最终文件名为 文件散列值.扩展名,合并成功后自动清理分片临时目录。

[!WARNING]

  1. 分片上传必须使用 Storage::disk(MODE_LOCAL, false) 方式调用(跳过 HTTP 文件上传校验)
  2. 合并过程有独占锁,重复触发会提示"文件正在合并中"
  3. 中断未合并的分片临时目录(chunk_path 下)暂不自动清理,请由业务侧定期清理

☁️ 大文件分片上传(云端)

阿里云 OSS、腾讯云 COS、AWS S3、七牛云同样支持 uploadChunk / chunkProgress / mergeChunk,调用方式与本地完全一致,仅 disk 不同:

🧪 端到端测试示例见 example/:同一套路由通过 disk 参数切换本地与云端,如 DISK=oss ./chunk-upload-test.sh video.mp4

实现方式

云端 实现
阿里云 OSS / 腾讯云 COS / AWS S3 厂商原生 Multipart Upload:首片自动 initiate,逐片 uploadPart,合并时 completecopy 为最终对象并删除临时对象
七牛云 分片本地暂存,合并后整体 putFile 上传(SDK 内部自动断点续传)

[!WARNING]

  1. 厂商对非末尾分片有最小尺寸要求:S3 ≥ 5MB、COS ≥ 1MB、OSS ≥ 100KB。默认 chunk_size 5MB 满足全部厂商,调小需谨慎
  2. 中断且未合并的云端 Multipart 会话(含已上传分片)会长期占用存储桶,本库不提供 abort 接口,请由业务侧调用厂商 API 中止,或为存储桶配置"未完成分片上传"生命周期清理规则
  3. 七牛云中途中断的本地暂存分片位于 chunk_path,同样需业务侧定期清理

🧪 代码质量

工具链:Mago(格式化 / lint / 静态分析)+ Pest(单元测试)


**如果这个项目对你有帮助,欢迎 ⭐ Star 支持一下!** Made with ❤️ by [Tinywan](https://github.com/Tinywan) · [MIT License](https://packagist.org/packages/tinywan/storage)

All versions of storage with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
workerman/webman-framework Version ^1.5.4||^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tinywan/storage contains the following files

Loading the files please wait ...