div-art/filemanager
Composer 安装命令:
composer require div-art/filemanager
包简介
create filemanager file
README 文档
README
Filemanager package for Laravel 5.5
Installation
To install, run the following in your project directory:
$ composer require div-art/filemanager
Then in config/app.php add the following to the providers array:
\Divart\Filemanager\FilemanagerServiceProvider::class,
'Tymon\JWTAuth\Providers\JWTAuthServiceProvider',
Also in config/app.php, add the Facade class to the aliases array:
'Filemanager' => \Divart\Filemanager\Facades\Filemanager::class,
'JWTAuth' => 'Tymon\JWTAuth\Facades\JWTAuth'
Configuration
To publish Filemanager's configuration file, run the following vendor:publish command:
php artisan vendor:publish --provider="Divart\Filemanager\FilemanagerServiceProvider"
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider"
Now for token encryption, I need to generate a secret key by running following line of code :
php artisan jwt:secret
Now I will create middleware to check if the token is valid or not and also You can handle the exception if the token is expired.
php artisan make:middleware VerifyJWTToken
Using this middleware, you can filter the request and validate the JWT token. Now open your VerifyJWTToken middleware and put below line of code.
app/Http/Middleware/VerifyJWTToken.php pop-uptext
<?php
namespace App\Http\Middleware;
use Closure;
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
class VerifyJWTToken
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
try{
$user = JWTAuth::toUser($request->input('token'));
}catch (JWTException $e) {
if($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) {
return response()->json(['token_expired'], $e->getStatusCode());
}else if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
return response()->json(['token_invalid'], $e->getStatusCode());
}else{
return response()->json(['error'=>'Token is required']);
}
}
return $next($request);
}
}
The try block in handle method check if requested token is verified by JWTAuth or not if it is not verified then exception will be handled in catch block with their status.
Now register this middleware in your kernal to run during every HTTP request to your application. app/Http/Kernel.php
protected $routeMiddleware = [
...
'jwt.auth' => \App\Http\Middleware\VerifyJWTToken::class,
];
Usage
Add from ENV file:
#FILEMANAGER_LOCATION - File manager location
FILEMANAGER_LOCATION=myfilemanager
Since the file manager only works with authorized users, you need to make a connection to the database, and create a plaque for users with minimal fields email, password If you do not have it, you can do it using the command:
php artisan make:auth
Available routes
To work with the file manager you need to login by POST method, send an email address and password to this route to authorize and receive a token
http.youdomain.com/auth/login
File Manager Routes
All file manager paths have a prefix 'filemanager'
example:
method GET
{http.youdomain.com}/filemanager
this method open filemanager and scan him
method GET
{http.youdomain.com}/filemanager/folder/{path to folder?}
this route open this selected folder
method POST
{http.youdomain.com}/filemanager/folder/create/{path to folder?}
this method create new folder in this directory
Need to send data: 'name' - is name folder
method POST
{http.youdomain.com}/filemanager/file/create/{path to file?}
this method create file
Need to send: 'name' and 'data' where value name is name file and your expansion, 'data' is content file
method POST
{http.youdomain.com}/filemanager/file/upload/{path to file?}
this method upload file
method PUT
{http.youdomain.com}/filemanager/folder/update/{path to folder}
this method update(rename folder) selected folder in this directory
Need to send data: 'name', 'newname' where 'name' is name selected folder and 'newname' that new name folder
method PUT
{http.youdomain.com}/filemanager/file/update/{path to file?}
Need to send: 'name' and 'data' where value name is name file and your expansion, 'data' is content file
method DELETE
{http.youdomain.com}/filemanager/folder/delete/{path to folder}
this method delete selected folder in this directory
Need to send data: 'name', where value is name selected folder
method DELETE
{http.youdomain.com}/filemanager/file/delete/{path to file?}
Need to send: 'name' and the file is deleted
method GET
{http.youdomain.com}/filemanager/file/{filename}/folder/{path to file?}
this method return file data
method POST
{http.youdomain.com}/filemanager/folder/changelocation/{path to folder}
this method change location folder and the attachments in it are files
Need to send data: 'from', 'to'. 'from' - address from which of the derivatives, 'to' - where to move
method POST
{http.youdomain.com}/filemanager/file/changelocation/{path to folder?}
this method change location file Need to send data: 'from', 'to'. 'from' - address from which of the derivatives, 'to' - where to move
method POST
{http.youdomain.com}/filemanager/folder/{folder?}
this method accepts data for sorting items into a file manager
Need to send data: 'value' and 'type'. 'value' may be important 'size' or 'time', 'type' may be important 'SORT_ASC' or SORT_DESC. Defaul is 'value' = 'time', 'type' = SORT_ASC
License
The MIT License (MIT). Please see License File for more information."# Filemanager" "# Filemanager"
div-art/filemanager 适用场景与选型建议
div-art/filemanager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 div-art/filemanager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 div-art/filemanager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-30