intaro / file-uploader-bundle
Symfony2 组件,旨在简化文件上传过程
v2.1.0
2023-01-09 12:19 UTC
Requires
- php: ^7.4 | ^8.0
- knplabs/knp-gaufrette-bundle: ~0.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- phpstan/phpstan: ^1.8
This package is not auto-updated.
Last update: 2024-09-23 16:36:56 UTC
README
关于
这是一个 Symfony2 组件。该组件的目的是简化文件上传过程。文件上传到临时文件夹后,该组件会将文件移动到存储位置。
支持几种存储类型
- 本地文件系统
- Amazon S3
安装
在 composer.json 文件中添加组件依赖
{ "require": { "intaro/file-uploader-bundle": "dev-master", } }
在 AppKernel 中注册
// app/AppKernel.php class AppKernel extends SaasKernel { public function registerBundles() { $bundles = array( ... new Intaro\FileUploaderBundle\IntaroFileUploaderBundle(), ); } }
使用 composer 安装
$ composer update intaro/file-uploader-bundle
使用方法
在配置中
# app/config/config.yml intaro_file_uploader: uploaders: local: image: path: http://www.app.local/images/ create: true allowed_types: ['image/jpeg', 'image/png', 'image/gif'] document: directory: path/to/another/attach/dir create: true allowed_types: ['application/pdf', 'application/rtf', 'application/vnd.ms-office'] aws_s3: video: service_id: aws.client_service_name path: https://s3-us-west-2.amazonaws.com/bucket-name/iamges/ bucket_name: some_bucket options: create: true acl: public-read
在代码中
public function uploadAction() { $files = $this->getRequest()->files->get('file'); $this->get('intaro.video_uploader')->upload($file); }