mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 14:01:07 +00:00
Merge branch 'v5.1.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.1.0dev
This commit is contained in:
commit
0fd959d9b5
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user