put($path, $fileString); if (!$res) { throw new LogicException("临时储存失败"); } return $path; } /** * 读取并下载 * * @param $path * @return \Symfony\Component\HttpFoundation\StreamedResponse */ static public function getDownUrl($path) { $path = config('app.name') . '_temp/' . $path; // dd($path); $res = self::getDisk()->url($path); return $res; } static public function getDown($path) { $path = config('app.name') . '_temp/' . $path; // dd($path); $disk = self::getDisk(); // dd($oss); $res = $disk->read($path); $headers = []; $headers['Content-Type'] = $disk->mimeType($path); $headers['Content-Length'] = $disk->size($path); // dd($headers); $resp = response('', 200, $headers)->setContent($res); // dd($res); return $resp; } static public function path2url($path) { $new = substr($path, strpos($path, 'temp')); return $new; } /** * 获取本地驱动的临时文件一个 * * @return string */ static public function getTempLocalFile() { $file = sys_get_temp_dir() . '/' . uniqid(); // dd($file); return $file; } }