twom/laravel-file-manger 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

twom/laravel-file-manger

Composer 安装命令:

composer require twom/laravel-file-manger

包简介

Upload file and download it :)

README 文档

README

Installation:

composer require twom/laravel-file-manger

You must add the service provider to config/app.php

'providers' => [
	 // for laravel 5.8 and below
	 \Twom\FileManager\FileManagerServiceProvider::class,
];

Publish your config file and migrations

php artisan vendor:publish

Config:

config/filemanager.php

return [  
  "type" => "default",  
  
  "types" => [  
	  "default" => [  
		  "provider" => \Twom\FileManager\Types\File::class,  
		  "path" => "default_files/test/",  
		  "private" => false,  
		  "date_time_prefix" => true,  
		  "use_file_name_to_upload" => false,  
		  "secret" => "ashkdsjka#sdkdjfsj22188455$$#$%dsDFsdf",  
		  "download_link_expire" => 160, // minutes  
	  ],
      "image"   => [
          "provider" => \Twom\FileManager\Types\Image::class,
          "path"     => "images/upload/documents/",
          "sizes"    => ["16", "24", "32", "64", "128", "320"],
          "thumb"    => "320"
      ],
      "profile" => [
          "parent"           => "image",
          "path"             => "images/upload/profiles/",
          "date_time_prefix" => false,
      ],  
  ],  
];

Config Parameters

name type description
provider string (class name) provider class name, must be extended of Twom\FileManager\BaseType
path string file upload path
private boolean is private or no if is true so upload file in storage folder else if is false so upload file in public folder
date_time_prefix boolean if is true so upload file with /{year}/{month}/{day} prefix
use_file_name_to_upload boolean if is true we use of the file original name else we generate a random name
secret string secret key for generate download link and download file
download_link_expire boolean generated download link expire time
parent string parent type name
sizes array array of sizes and there are only for image type
thumb string or number size for thumb image and this is only for image type

Lets start to use:

Upload a file:

$file = request()->file('filename');
$upload = File::upload($file);

//	get file uploaded path
$filePath = $upload->getFilePath();

//	get file name  
$fileName = $upload->getName();

You can use of this methods:

method description
useFileNameToUpload($status = true) if is true we use of the file original name else we generate a random name
type($type = null) change type for upload if is null so use of default type
getFile($name = null) get file by name and return a \Twom\FileManager\Models\File
setPath($path) set file upload path
delete($filename) delete the file help by this provider type
getUploadPath() get upload path
dateTimePrefix($value = true) if is true so upload file with /{year}/{month}/{day} prefix
setName(string $name) set file name
setFormat(string $format) set format for file upload
isPrivate() if you call this so upload file in storage folder and your you don't have permission to access this file
isPublic() if you call this so upload file in public folder and has access to this file

Examples:

$file = request()->file('filename');  
$upload = \Twom\FileManager\Facades\File::setName('your specific name')  
	 ->isPrivate()  
	 ->setFormat('png')  
	 ->dateTimePrefix()  
	 ->upload($file);
//	get file uploaded path => if is public you can use it for download
dd($upload->getFilePath());
$file = File::getFile("file uploaded name");  
$file->name;  
$file->path;  
$file->type; // config file selected type  
$file->isPrivate;  
$file->isPublic;  
$file->generateLink();  
  
// return response download  
// $file->download();

Change type:

$file = request()->file('filename');  
$upload = \Twom\FileManager\Facades\File::type("type_name") // type name in config file (filemanager.php)
    ->upload($file);

twom/laravel-file-manger 适用场景与选型建议

twom/laravel-file-manger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 188 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「file」 「file manager」 「laravel」 「laravel file manager」 「php file manager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 twom/laravel-file-manger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 twom/laravel-file-manger 我们能提供哪些服务?
定制开发 / 二次开发

基于 twom/laravel-file-manger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 188
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-03-05