作者 lyh

gx

... ... @@ -32,13 +32,46 @@ class FileManageController extends BaseController
$this->upload_config = $project['upload_config'];
}
/**
* @remark :列表
* @name :index
* @author :lyh
* @method :post
* @time :2023/12/28 17:03
*/
public function index(FileManage $fileManage){
$this->map['project_id'] = $this->user['project_id'];
$this->request['name'] && $this->map['name'] = ['like','%'.$this->request['name'].'%'];
$lists = $fileManage->lists($this->map, $this->page, $this->row);
foreach ($lists as $k => $v){
$v['download_url'] = url('b/file_manager_downLoad?path='.$v['path']);
$lists[$k] = $v;
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :下载方法
* @name :downLoad
* @author :lyh
* @method :post
* @time :2023/12/28 17:18
*/
public function downLoad(){
$file_model = new FileManage();
$info = $file_model->read(['hash' => $this->param['hash']]);
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$fileUrl = 'https://file.globalso.com'.$info['path'];
// 设置响应头
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $info['name'] . '"');
// 下载文件
readfile($fileUrl);
}
public function upload(Request $request, FileManage $fileManage){
$request->validate([
'file'=>['required'],
... ...
... ... @@ -470,6 +470,7 @@ Route::group([], function () {
Route::any('/login', [\App\Http\Controllers\Bside\LoginController::class, 'login'])->name('login');
Route::any('/projectLogin', [\App\Http\Controllers\Bside\LoginController::class, 'projectLogin'])->name('projectLogin');
Route::any('/ceshi', [\App\Http\Controllers\Bside\LoginController::class, 'ceshi'])->name('ceshi');
Route::any('/file_manager_downLoad', [\App\Http\Controllers\Bside\FileManage\FileManageController::class, 'downLoad'])->name('file_manager_downLoad');
Route::any('/stringTranslation', [\App\Http\Controllers\Bside\LoginController::class, 'stringTranslation'])->name('stringTranslation');
Route::any('/sendLoginSms', [\App\Http\Controllers\Bside\LoginController::class, 'sendLoginSms'])->name('sendLoginSms');
Route::any('/autologin', [\App\Http\Controllers\Bside\LoginController::class, 'autologin'])->name('autologin');
... ...