Commit b3a2dc3f by xmy

商品修改

parent e8a1cfe5
......@@ -26,10 +26,8 @@ class Upload
public function __construct(array $config = [])
{
if (empty($config)) {
/**@var Config */
$bConfig = \Swoft\App::getBean('config');
$bConfig->load('@vendor/hdll/services/src/Common/Config');
$config = $bConfig->get('qCloud');
$config = include alias('@vendor/hdll/services/src/Common/Config').'/config.php';
$config = $config['qCloud'];
}
$this->Bucket = $config['Bucket'];
$this->Region = $config['Region'];
......@@ -68,4 +66,27 @@ class Upload
}
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