You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
59 lines
1.9 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\adminapi\controller\upload;
|
|
|
|
use app\service\admin\upload\DirectUploadService;
|
|
use core\base\BaseAdminController;
|
|
use think\Response;
|
|
|
|
/**
|
|
* 对象存储直传控制器
|
|
*/
|
|
class DirectUpload extends BaseAdminController
|
|
{
|
|
/**
|
|
* 获取对象存储直传临时凭证
|
|
* @return Response
|
|
*/
|
|
public function getUploadCredentials()
|
|
{
|
|
$data = $this->request->params([
|
|
['file_type', 'image'], // 文件类型:image、video、document
|
|
['file_name', ''], // 文件名(可选)
|
|
]);
|
|
|
|
$service = new DirectUploadService();
|
|
$result = $service->getUploadCredentials($data['file_type'], $data['file_name']);
|
|
|
|
return success($result);
|
|
}
|
|
|
|
/**
|
|
* 确认文件上传完成,将文件信息保存到数据库
|
|
* @return Response
|
|
*/
|
|
public function confirmUpload()
|
|
{
|
|
$data = $this->request->params([
|
|
['file_url', ''], // 文件URL
|
|
['file_name', ''], // 文件名
|
|
['file_size', 0], // 文件大小
|
|
['file_type', 'image'], // 文件类型
|
|
['storage_type', 'tencent'], // 存储类型
|
|
]);
|
|
|
|
$service = new DirectUploadService();
|
|
$result = $service->confirmUpload($data);
|
|
|
|
return success($result);
|
|
}
|
|
}
|