mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]修改文件存储服务, 严格参数异常处理
This commit is contained in:
parent
d864aff884
commit
99b3b8ae80
@ -89,7 +89,7 @@ class FileService
|
|||||||
case 'oss':
|
case 'oss':
|
||||||
return self::getBaseUriOss() . $filename;
|
return self::getBaseUriOss() . $filename;
|
||||||
}
|
}
|
||||||
return false;
|
throw new \think\Exception('未设置存储方式,无法获取到文件对应URL地址');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,11 +129,12 @@ class FileService
|
|||||||
}
|
}
|
||||||
return $isClient ? 'http://upload-na0.qiniup.com' : 'http://up-na0.qiniup.com';
|
return $isClient ? 'http://upload-na0.qiniup.com' : 'http://up-na0.qiniup.com';
|
||||||
case '华南':
|
case '华南':
|
||||||
default:
|
|
||||||
if ($isHttps) {
|
if ($isHttps) {
|
||||||
return $isClient ? 'https://upload-z2.qiniup.com' : 'https://up-z2.qiniup.com';
|
return $isClient ? 'https://upload-z2.qiniup.com' : 'https://up-z2.qiniup.com';
|
||||||
}
|
}
|
||||||
return $isClient ? 'http://upload-z2.qiniup.com' : 'http://up-z2.qiniup.com';
|
return $isClient ? 'http://upload-z2.qiniup.com' : 'http://up-z2.qiniup.com';
|
||||||
|
default:
|
||||||
|
throw new \think\Exception('未配置七牛云存储区域');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,8 +174,10 @@ class FileService
|
|||||||
return 'https://' . sysconf('storage_qiniu_domain') . '/';
|
return 'https://' . sysconf('storage_qiniu_domain') . '/';
|
||||||
case 'http':
|
case 'http':
|
||||||
return 'http://' . sysconf('storage_qiniu_domain') . '/';
|
return 'http://' . sysconf('storage_qiniu_domain') . '/';
|
||||||
default:
|
case 'auto':
|
||||||
return '//' . sysconf('storage_qiniu_domain') . '/';
|
return '//' . sysconf('storage_qiniu_domain') . '/';
|
||||||
|
default:
|
||||||
|
throw new \think\Exception('未设置七牛云文件地址协议');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +194,10 @@ class FileService
|
|||||||
return 'https://' . sysconf('storage_oss_domain') . '/';
|
return 'https://' . sysconf('storage_oss_domain') . '/';
|
||||||
case 'http':
|
case 'http':
|
||||||
return 'http://' . sysconf('storage_oss_domain') . '/';
|
return 'http://' . sysconf('storage_oss_domain') . '/';
|
||||||
default:
|
case 'auto':
|
||||||
return '//' . sysconf('storage_oss_domain') . '/';
|
return '//' . sysconf('storage_oss_domain') . '/';
|
||||||
|
default:
|
||||||
|
throw new \think\Exception('未设置阿里云文件地址协议');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,9 +261,9 @@ class FileService
|
|||||||
case 'oss':
|
case 'oss':
|
||||||
$ossClient = new OssClient(sysconf('storage_oss_keyid'), sysconf('storage_oss_secret'), self::getBaseUriOss(), true);
|
$ossClient = new OssClient(sysconf('storage_oss_keyid'), sysconf('storage_oss_secret'), self::getBaseUriOss(), true);
|
||||||
return $ossClient->getObject(sysconf('storage_oss_bucket'), $filename);
|
return $ossClient->getObject(sysconf('storage_oss_bucket'), $filename);
|
||||||
|
default:
|
||||||
|
throw new \think\Exception('未配置读取文件的存储方法');
|
||||||
}
|
}
|
||||||
Log::error("通过{$storage}读取文件{$filename}的不存在!");
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user