Commit 5f798f59 authored by chentianyu's avatar chentianyu

oss 路径加appName

parent 62a51b86
......@@ -33,6 +33,11 @@ class UploadOssService
*/
private $appDev;
/**
* @var string
*/
private $appName;
public static $options = [
'maxSize' => 10 * 1024 * 1024, // 文件大小,10M
'mime' => ['jpeg', 'png', 'gif', 'jpg', 'svg', 'txt', 'pdf', 'xlsx', 'xls', 'doc', 'docx', 'rar', 'zip', 'csv'], // 允许上传的文件类型
......@@ -45,6 +50,7 @@ class UploadOssService
$ossConfig = $this->config->get('file.storage.oss');
$this->urlPrefix = 'https://' . $ossConfig['bucket'] . '.' . $ossConfig['endpoint'] . '/';
$this->appDev = $this->config->get('app_env');
$this->appName = $this->config->get('app_name');
}
/**
......@@ -61,7 +67,7 @@ class UploadOssService
$clientFilename = $image->getClientFilename();
$fileName = $uniqueFileName ? ($this->genUniqueFileName() . '.' . $ext) : $clientFilename;
$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);
$model = new FileModel();
$model = $model->newInstance([
......@@ -91,7 +97,7 @@ class UploadOssService
$ext = $file->getExtension();
$clientFilename = $file->getClientFilename();
$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);
$model = new FileModel();
$model = $model->newInstance([
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment