63 lines
1.2 KiB
PHP
63 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace App\Http\Controllers\Api;
|
||
|
||
use App\BaseApp\BaseController;
|
||
use App\Service\common\UploadService;
|
||
use Illuminate\Http\JsonResponse;
|
||
|
||
class UploadController extends BaseController
|
||
{
|
||
//
|
||
|
||
public function __construct()
|
||
{
|
||
parent::__construct();
|
||
$this->service = UploadService::getInstance();
|
||
}
|
||
|
||
/**
|
||
* 图片上传
|
||
* @Method POST
|
||
* @return JsonResponse
|
||
* @throws \Exception
|
||
*/
|
||
public function image()
|
||
{
|
||
$file = request()->file('file');
|
||
return jok(
|
||
$this->service->uploadImage($file),
|
||
'上传成功'
|
||
);
|
||
}
|
||
|
||
/**
|
||
* 视频上传
|
||
* @Method POST
|
||
* @return JsonResponse
|
||
*/
|
||
public function video()
|
||
{
|
||
$file = request()->file('file');
|
||
return jok(
|
||
$this->service->uploadVideo($file),
|
||
'上传成功'
|
||
);
|
||
}
|
||
|
||
/**
|
||
* 文档上传(PDF 等)
|
||
* @Method POST
|
||
* @return JsonResponse
|
||
* @throws \Exception
|
||
*/
|
||
public function file()
|
||
{
|
||
$file = request()->file('file');
|
||
return jok(
|
||
$this->service->uploadDocument($file),
|
||
'上传成功'
|
||
);
|
||
}
|
||
}
|