Merge branch 'hotfix/series' into develop
This commit is contained in:
@@ -87,12 +87,15 @@ class UploadController
|
|||||||
}
|
}
|
||||||
$originalName = $file->getUploadName();
|
$originalName = $file->getUploadName();
|
||||||
|
|
||||||
|
$ossservice = new OssService();
|
||||||
|
$mimes = $ossservice->getMimeTypes(['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'zip', 'rar']);
|
||||||
|
|
||||||
$result = Storage::adapter('oss')
|
$result = Storage::adapter('oss')
|
||||||
->path('x_server/' . $sceneUrl . date('Ymd'))
|
->path('x_server/' . $sceneUrl . date('Ymd'))
|
||||||
->size(1024*1024*5)
|
->size(1024*1024*5)
|
||||||
|
->extYes($mimes)
|
||||||
->upload($file);
|
->upload($file);
|
||||||
|
|
||||||
$ossservice = new OssService();
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'original_name' => $originalName,
|
'original_name' => $originalName,
|
||||||
|
|||||||
@@ -76,4 +76,38 @@ class OssService
|
|||||||
throw new BusinessException('Delete Error: ' . $th->getMessage());
|
throw new BusinessException('Delete Error: ' . $th->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对应的 MIME 类型
|
||||||
|
*/
|
||||||
|
public function getMimeTypes($extensions)
|
||||||
|
{
|
||||||
|
$mimeMap = [
|
||||||
|
'jpg' => 'image/jpeg',
|
||||||
|
'jpeg' => 'image/jpeg',
|
||||||
|
'png' => 'image/png',
|
||||||
|
'gif' => 'image/gif',
|
||||||
|
'bmp' => 'image/bmp',
|
||||||
|
'webp' => 'image/webp',
|
||||||
|
'pdf' => 'application/pdf',
|
||||||
|
'doc' => 'application/msword',
|
||||||
|
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
'xls' => 'application/vnd.ms-excel',
|
||||||
|
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
|
'ppt' => 'application/vnd.ms-powerpoint',
|
||||||
|
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||||
|
'txt' => 'text/plain',
|
||||||
|
'zip' => 'application/zip',
|
||||||
|
'rar' => 'application/x-rar-compressed'
|
||||||
|
];
|
||||||
|
|
||||||
|
$mimes = [];
|
||||||
|
foreach ($extensions as $ext) {
|
||||||
|
if (isset($mimeMap[$ext])) {
|
||||||
|
$mimes[] = $mimeMap[$ext];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_unique($mimes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user