mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-21 03:17:05 +08:00
59 lines
1.1 KiB
PHP
59 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Home\Controllers;
|
|
|
|
use App\Services\MyStorage as StorageService;
|
|
use App\Validators\Validator as AppValidator;
|
|
|
|
/**
|
|
* @RoutePrefix("/upload")
|
|
*/
|
|
class UploadController extends Controller
|
|
{
|
|
|
|
public function initialize()
|
|
{
|
|
$authUser = $this->getAuthUser();
|
|
|
|
$validator = new AppValidator();
|
|
|
|
$validator->checkAuthUser($authUser->id);
|
|
}
|
|
|
|
/**
|
|
* @Post("/avatar/img", name="home.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("/im/img", name="home.upload.im_img")
|
|
*/
|
|
public function uploadImImageAction()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @Post("/im/file", name="home.upload.im_file")
|
|
*/
|
|
public function uploadImFileAction()
|
|
{
|
|
|
|
}
|
|
|
|
} |