Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zfegg/attachment-handler
通用附件上传处理
https://github.com/zfegg/attachment-handler
Last synced: about 2 months ago
JSON representation
通用附件上传处理
- Host: GitHub
- URL: https://github.com/zfegg/attachment-handler
- Owner: zfegg
- License: mit
- Created: 2022-10-23T13:28:30.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-07-23T09:44:13.000Z (over 1 year ago)
- Last Synced: 2023-09-14T09:29:55.335Z (over 1 year ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
附件上传处理器
================[![GitHub Actions: Run tests](https://github.com/zfegg/attachment-handler/workflows/qa/badge.svg)](https://github.com/zfegg/attachment-handler/actions?query=workflow%3A%22qa%22)
[![Coverage Status](https://coveralls.io/repos/github/zfegg/attachment-handler/badge.svg?branch=master)](https://coveralls.io/github/zfegg/attachment-handler?branch=master)
[![Latest Stable Version](https://poser.pugx.org/zfegg/attachment-handler/v/stable.png)](https://packagist.org/packages/zfegg/attachment-handler)附件上传处理器
安装 / Installation
------------```bash
composer require zfegg/attachment-handler
```使用 / Usage
------### 在Mezzio中使用
```php
// File config/config.php
// Add ConfigProvidernew ConfigAggregator([
Zfegg\AttachmentHandler\ConfigProvider::class,
]);
```配置示例:
```php
use Zfegg\AttachmentHandler\AttachmentHandler;
use League\Flysystem\Filesystem;return [
AttachmentHandler::class => [
'rules' => [
'UploadExtension' => [
'options' => ['allowed' => ['jpg', 'jpeg', 'png', 'gif', 'bmp']],
'messageTemplate' => '文件必须为图片格式 (jpg, jpeg, png, gif, bmp)',
],
'UploadSize' => [
'options' => ['size' => '2M'],
'messageTemplate' => '上传文件必须小于 {max}'
],
],
'storage' => 'images/{date}/{uniqid}.{ext}',
'url' => '/uploads'
],
Filesystem::class => [
// 上传目录,支持 url schema
// ftp://user:[email protected]/uploads
// sftp://user:[email protected]/uploads
// memory://temp
'path' => 'public/uploads'
]
]
```