|
@@ -32,13 +32,46 @@ class FileManageController extends BaseController |
|
@@ -32,13 +32,46 @@ class FileManageController extends BaseController |
|
32
|
$this->upload_config = $project['upload_config'];
|
32
|
$this->upload_config = $project['upload_config'];
|
|
33
|
}
|
33
|
}
|
|
34
|
|
34
|
|
|
|
|
35
|
+ /**
|
|
|
|
36
|
+ * @remark :列表
|
|
|
|
37
|
+ * @name :index
|
|
|
|
38
|
+ * @author :lyh
|
|
|
|
39
|
+ * @method :post
|
|
|
|
40
|
+ * @time :2023/12/28 17:03
|
|
|
|
41
|
+ */
|
|
35
|
public function index(FileManage $fileManage){
|
42
|
public function index(FileManage $fileManage){
|
|
36
|
$this->map['project_id'] = $this->user['project_id'];
|
43
|
$this->map['project_id'] = $this->user['project_id'];
|
|
37
|
$this->request['name'] && $this->map['name'] = ['like','%'.$this->request['name'].'%'];
|
44
|
$this->request['name'] && $this->map['name'] = ['like','%'.$this->request['name'].'%'];
|
|
38
|
$lists = $fileManage->lists($this->map, $this->page, $this->row);
|
45
|
$lists = $fileManage->lists($this->map, $this->page, $this->row);
|
|
|
|
46
|
+ foreach ($lists as $k => $v){
|
|
|
|
47
|
+ $v['download_url'] = url('b/file_manager_downLoad?path='.$v['path']);
|
|
|
|
48
|
+ $lists[$k] = $v;
|
|
|
|
49
|
+ }
|
|
39
|
$this->response('success',Code::SUCCESS,$lists);
|
50
|
$this->response('success',Code::SUCCESS,$lists);
|
|
40
|
}
|
51
|
}
|
|
41
|
|
52
|
|
|
|
|
53
|
+ /**
|
|
|
|
54
|
+ * @remark :下载方法
|
|
|
|
55
|
+ * @name :downLoad
|
|
|
|
56
|
+ * @author :lyh
|
|
|
|
57
|
+ * @method :post
|
|
|
|
58
|
+ * @time :2023/12/28 17:18
|
|
|
|
59
|
+ */
|
|
|
|
60
|
+ public function downLoad(){
|
|
|
|
61
|
+ $file_model = new FileManage();
|
|
|
|
62
|
+ $info = $file_model->read(['hash' => $this->param['hash']]);
|
|
|
|
63
|
+ if ($info === false) {
|
|
|
|
64
|
+ $this->response('指定文件不存在!', Code::USER_ERROR);
|
|
|
|
65
|
+ }
|
|
|
|
66
|
+ $fileUrl = 'https://file.globalso.com'.$info['path'];
|
|
|
|
67
|
+ // 设置响应头
|
|
|
|
68
|
+ header('Content-Description: File Transfer');
|
|
|
|
69
|
+ header('Content-Type: application/octet-stream');
|
|
|
|
70
|
+ header('Content-Disposition: attachment; filename="' . $info['name'] . '"');
|
|
|
|
71
|
+ // 下载文件
|
|
|
|
72
|
+ readfile($fileUrl);
|
|
|
|
73
|
+ }
|
|
|
|
74
|
+
|
|
42
|
public function upload(Request $request, FileManage $fileManage){
|
75
|
public function upload(Request $request, FileManage $fileManage){
|
|
43
|
$request->validate([
|
76
|
$request->validate([
|
|
44
|
'file'=>['required'],
|
77
|
'file'=>['required'],
|