Loading src/UploadOss/UploadOssService.php +8 −2 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,11 @@ class UploadOssService */ */ private $appDev; private $appDev; /** * @var string */ private $appName; public static $options = [ public static $options = [ 'maxSize' => 10 * 1024 * 1024, // 文件大小,10M 'maxSize' => 10 * 1024 * 1024, // 文件大小,10M 'mime' => ['jpeg', 'png', 'gif', 'jpg', 'svg', 'txt', 'pdf', 'xlsx', 'xls', 'doc', 'docx', 'rar', 'zip', 'csv'], // 允许上传的文件类型 'mime' => ['jpeg', 'png', 'gif', 'jpg', 'svg', 'txt', 'pdf', 'xlsx', 'xls', 'doc', 'docx', 'rar', 'zip', 'csv'], // 允许上传的文件类型 Loading @@ -45,6 +50,7 @@ class UploadOssService $ossConfig = $this->config->get('file.storage.oss'); $ossConfig = $this->config->get('file.storage.oss'); $this->urlPrefix = 'https://' . $ossConfig['bucket'] . '.' . $ossConfig['endpoint'] . '/'; $this->urlPrefix = 'https://' . $ossConfig['bucket'] . '.' . $ossConfig['endpoint'] . '/'; $this->appDev = $this->config->get('app_env'); $this->appDev = $this->config->get('app_env'); $this->appName = $this->config->get('app_name'); } } /** /** Loading @@ -61,7 +67,7 @@ class UploadOssService $clientFilename = $image->getClientFilename(); $clientFilename = $image->getClientFilename(); $fileName = $uniqueFileName ? ($this->genUniqueFileName() . '.' . $ext) : $clientFilename; $fileName = $uniqueFileName ? ($this->genUniqueFileName() . '.' . $ext) : $clientFilename; $options = ['mime' => ['jpeg', 'png', 'gif', 'jpg', 'svg']]; $options = ['mime' => ['jpeg', 'png', 'gif', 'jpg', 'svg']]; $filePath = 'oss2/' . $this->appDev . "/$module/images/" . today() . "/$userId/" . $clientFilename; $filePath = 'oss2/' . $this->appDev . "/" . $this->appName . "/$module/images/" . today() . "/$userId/" . $clientFilename; $this->upload($image, $filePath, $options); $this->upload($image, $filePath, $options); $model = new FileModel(); $model = new FileModel(); $model = $model->newInstance([ $model = $model->newInstance([ Loading Loading @@ -91,7 +97,7 @@ class UploadOssService $ext = $file->getExtension(); $ext = $file->getExtension(); $clientFilename = $file->getClientFilename(); $clientFilename = $file->getClientFilename(); $fileName = $uniqueFileName ? ($this->genUniqueFileName() . '.' . $ext) : $clientFilename; $fileName = $uniqueFileName ? ($this->genUniqueFileName() . '.' . $ext) : $clientFilename; $filePath = 'oss2/' . $this->appDev . "/$module/files/" . today() . "/$userId/" . $clientFilename; $filePath = 'oss2/' . $this->appDev . "/" . $this->appName . "/$module/files/" . today() . "/$userId/" . $clientFilename; $this->upload($file, $filePath, $options); $this->upload($file, $filePath, $options); $model = new FileModel(); $model = new FileModel(); $model = $model->newInstance([ $model = $model->newInstance([ Loading Loading
src/UploadOss/UploadOssService.php +8 −2 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,11 @@ class UploadOssService */ */ private $appDev; private $appDev; /** * @var string */ private $appName; public static $options = [ public static $options = [ 'maxSize' => 10 * 1024 * 1024, // 文件大小,10M 'maxSize' => 10 * 1024 * 1024, // 文件大小,10M 'mime' => ['jpeg', 'png', 'gif', 'jpg', 'svg', 'txt', 'pdf', 'xlsx', 'xls', 'doc', 'docx', 'rar', 'zip', 'csv'], // 允许上传的文件类型 'mime' => ['jpeg', 'png', 'gif', 'jpg', 'svg', 'txt', 'pdf', 'xlsx', 'xls', 'doc', 'docx', 'rar', 'zip', 'csv'], // 允许上传的文件类型 Loading @@ -45,6 +50,7 @@ class UploadOssService $ossConfig = $this->config->get('file.storage.oss'); $ossConfig = $this->config->get('file.storage.oss'); $this->urlPrefix = 'https://' . $ossConfig['bucket'] . '.' . $ossConfig['endpoint'] . '/'; $this->urlPrefix = 'https://' . $ossConfig['bucket'] . '.' . $ossConfig['endpoint'] . '/'; $this->appDev = $this->config->get('app_env'); $this->appDev = $this->config->get('app_env'); $this->appName = $this->config->get('app_name'); } } /** /** Loading @@ -61,7 +67,7 @@ class UploadOssService $clientFilename = $image->getClientFilename(); $clientFilename = $image->getClientFilename(); $fileName = $uniqueFileName ? ($this->genUniqueFileName() . '.' . $ext) : $clientFilename; $fileName = $uniqueFileName ? ($this->genUniqueFileName() . '.' . $ext) : $clientFilename; $options = ['mime' => ['jpeg', 'png', 'gif', 'jpg', 'svg']]; $options = ['mime' => ['jpeg', 'png', 'gif', 'jpg', 'svg']]; $filePath = 'oss2/' . $this->appDev . "/$module/images/" . today() . "/$userId/" . $clientFilename; $filePath = 'oss2/' . $this->appDev . "/" . $this->appName . "/$module/images/" . today() . "/$userId/" . $clientFilename; $this->upload($image, $filePath, $options); $this->upload($image, $filePath, $options); $model = new FileModel(); $model = new FileModel(); $model = $model->newInstance([ $model = $model->newInstance([ Loading Loading @@ -91,7 +97,7 @@ class UploadOssService $ext = $file->getExtension(); $ext = $file->getExtension(); $clientFilename = $file->getClientFilename(); $clientFilename = $file->getClientFilename(); $fileName = $uniqueFileName ? ($this->genUniqueFileName() . '.' . $ext) : $clientFilename; $fileName = $uniqueFileName ? ($this->genUniqueFileName() . '.' . $ext) : $clientFilename; $filePath = 'oss2/' . $this->appDev . "/$module/files/" . today() . "/$userId/" . $clientFilename; $filePath = 'oss2/' . $this->appDev . "/" . $this->appName . "/$module/files/" . today() . "/$userId/" . $clientFilename; $this->upload($file, $filePath, $options); $this->upload($file, $filePath, $options); $model = new FileModel(); $model = new FileModel(); $model = $model->newInstance([ $model = $model->newInstance([ Loading