uploadCoverImage(); if (!$file) { return $this->jsonError(['msg' => '上传文件失败']); } $data = [ 'src' => $service->getImageUrl($file->path), 'title' => $file->name, ]; return $this->jsonSuccess(['data' => $data]); } /** * @Post("/avatar/img", name="admin.upload.avatar_img") */ public function uploadAvatarImageAction() { $service = new StorageService(); $file = $service->uploadAvatarImage(); if (!$file) { return $this->jsonError(['msg' => '上传文件失败']); } $data = [ 'src' => $service->getImageUrl($file->path), 'title' => $file->name, ]; return $this->jsonSuccess(['data' => $data]); } /** * @Post("/content/img", name="admin.upload.content_img") */ public function uploadContentImageAction() { $service = new StorageService(); $file = $service->uploadContentImage(); if (!$file) { return $this->jsonError(['msg' => '上传文件失败']); } $data = [ 'src' => $service->getImageUrl($file->path), 'title' => $file->name, ]; return $this->jsonSuccess(['data' => $data]); } /** * @Get("/sign", name="admin.upload.sign") */ public function signatureAction() { $service = new StorageService(); $token = $service->getFederationToken(); $data = [ 'credentials' => $token->getCredentials(), 'expiredTime' => $token->getExpiredTime(), 'startTime' => time(), ]; return $this->jsonSuccess($data); } }