ruvents/spiral-upload
最新稳定版本:0.1.0
Composer 安装命令:
composer require ruvents/spiral-upload
包简介
Upload management
README 文档
README
Upload management package with misc helpers.
Installation
composer require ruvents/spiral-upload
Then add UploadBootloader to your App.php:
use Ruvents\SpiralUpload\UploadBootloader; class App extends Kernel { protected const LOAD = [ ... UploadBootloader::class, ] }
Configuration
Put the following code into file app/config/upload.php:
<?php declare(strict_types=1); return [ 'uploadClass' => Upload::class, // Custom UploadInterface implementation class. 'urlPrefix' => 'https://foo.bar/uploads/', // Public URL to uploads. Example: // https://foo.bar/uploads/f8/some-upload.png -- full URL to upload // https://foo.bar/uploads -- URL prefix // f8/some-upload.png -- relative path to upload ];
Use
Use UploadManager for upload-relative tasks:
public function manageUploads(UploadManager $manager) { // Create upload from file path. $upload = $manager->create('/path/to/file.txt', 'file.txt'); // Create upload from resource. $upload = $manager->create($handle = fopen('/path/to/file.txt', 'r'), 'file.txt'); fclose($handle); // Or from UploadedFileInterface. $stream = clone $uploadedFile->getStream(); $upload = $manager->create($stream->detach(), 'file.txt'); // Get full URL of upload. $url = $manager->url($upload); // Delete stored file associated with upload. $manager->delete($upload); }
统计信息
- 总下载量: 2.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-11-23