fix: 客户端无法下载聊天文件的问题

This commit is contained in:
kuaifan
2022-01-24 15:18:35 +08:00
parent 870276fa48
commit 1ab8a19f8e
8 changed files with 119 additions and 13 deletions
@@ -19,6 +19,7 @@ use App\Module\Base;
use Carbon\Carbon;
use Illuminate\Support\Arr;
use Request;
use Response;
/**
* @apiDefine project
@@ -1082,6 +1083,40 @@ class ProjectController extends AbstractController
return Base::retSuccess('success', $file);
}
/**
* @api {get} api/project/task/filedown 22. 下载任务文件
*
* @apiDescription 需要token身份(限:项目、任务负责人)
* @apiVersion 1.0.0
* @apiGroup project
* @apiName task__filedown
*
* @apiParam {Number} file_id 文件ID
*
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function task__filedown()
{
User::auth();
//
$file_id = intval(Request::input('file_id'));
//
$file = ProjectTaskFile::find($file_id);
if (empty($file)) {
abort(403, "This file not exist.");
}
//
try {
ProjectTask::userTask($file->task_id, true, true);
} catch (\Exception $e) {
abort(403, $e->getMessage() ?: "This file not support download.");
}
//
return Response::download(public_path($file->getRawOriginal('path')), $file->name);
}
/**
* @api {post} api/project/task/add 23. 添加任务
*