Merge branch 'v5.1.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.1.0dev

This commit is contained in:
evoxwht 2023-06-13 16:52:47 +08:00
commit 0fd959d9b5
2 changed files with 20 additions and 6 deletions

View File

@ -19,6 +19,7 @@ use app\services\product\product\StoreProductServices;
use crmeb\services\FileService;
use app\services\other\UploadService;
use think\facade\App;
use think\Request;
/**
* Class StoreProduct
@ -339,10 +340,22 @@ class StoreProduct extends AuthController
* @return mixed
* @throws \Exception
*/
public function getTempKeys()
public function getTempKeys(Request $request)
{
$upload = UploadService::init();
$re = $upload->getTempKeys();
$type = (int)sys_config('upload_type', 1);
$key = $request->get('key', '');
$path = $request->get('path', '');
$contentType = $request->get('contentType', '');
if ($type === 5) {
if (!$key || !$contentType) {
return app('json')->fail('缺少参数');
}
$url = $upload->getTempKeys($key, $path, $contentType);
$re = ['url' => $url];
} else {
$re = $upload->getTempKeys();
}
return $re ? app('json')->success($re) : app('json')->fail(100016);
}

View File

@ -345,17 +345,18 @@ class Jdoss extends BaseUpload
* 获取OSS上传密钥
* @return mixed|void
*/
public function getTempKeys($key = '', $path = '', $expires = '+10 minutes')
public function getTempKeys($key = '', $path = '', $contentType = '', $expires = '+10 minutes')
{
try {
$app = $this->app();
$cmd = $app->getCommand([
$cmd = $app->getCommand(
'PutObject', [
'Bucket' => $this->storageName,
'Key' => $key,
'SourceFile' => $path
'SourceFile' => $path,
'ContentType' => $contentType
]
]);
);
$request = $app->createPresignedRequest($cmd, $expires);
return (string)$request->getUri();
} catch (\Throwable $e) {