<?php // +---------------------------------------------------------------------- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ] // +---------------------------------------------------------------------- // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved. // +---------------------------------------------------------------------- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 // +---------------------------------------------------------------------- // | Author: CRMEB Team <admin@crmeb.com> // +---------------------------------------------------------------------- namespace app\api\controller; use crmeb\services\CacheService; use think\Response; class IndexController { /** * 下载文件 * @param string $key * @return Response|\think\response\File */ public function download(string $key = '') { if (!$key) { return Response::create()->code(500); } $fileName = CacheService::get($key); if (is_array($fileName) && isset($fileName['path']) && isset($fileName['fileName']) && $fileName['path'] && $fileName['fileName'] && file_exists($fileName['path'])) { CacheService::delete($key); return download($fileName['path'], $fileName['fileName']); } return Response::create()->code(500); } /** * 获取workerman请求域名 * @return mixed */ public function getWorkerManUrl() { return app('json')->success(getWorkerManUrl()); } }