Commit b3a2dc3f by xmy

商品修改

parent e8a1cfe5
...@@ -26,10 +26,8 @@ class Upload ...@@ -26,10 +26,8 @@ class Upload
public function __construct(array $config = []) public function __construct(array $config = [])
{ {
if (empty($config)) { if (empty($config)) {
/**@var Config */ $config = include alias('@vendor/hdll/services/src/Common/Config').'/config.php';
$bConfig = \Swoft\App::getBean('config'); $config = $config['qCloud'];
$bConfig->load('@vendor/hdll/services/src/Common/Config');
$config = $bConfig->get('qCloud');
} }
$this->Bucket = $config['Bucket']; $this->Bucket = $config['Bucket'];
$this->Region = $config['Region']; $this->Region = $config['Region'];
...@@ -68,4 +66,27 @@ class Upload ...@@ -68,4 +66,27 @@ class Upload
} }
return $result; return $result;
} }
public function uploadStream($stream, $name = '')
{
$cosClient = new Client(
[
'region' => $this->Region,
'credentials' => [
'secretId' => $this->SecretId,
'secretKey' => $this->SecretKey,
]
]
);
try {
$result = $cosClient->Upload(
$this->Bucket,
$name,
$stream
);
} catch (\Exception $e) {
throw new CommonException(['msg' => $e->getMessage()]);
}
return $result;
}
} }
\ No newline at end of file
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