Skip to content

Commit

Permalink
bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Mar 12, 2019
1 parent 7506d15 commit 1126c9f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,22 @@ $ composer require overtrue/flysystem-cos -vvv
use League\Flysystem\Filesystem;
use Overtrue\Flysystem\Cos\CosAdapter;

$secretId = 'AKIDsiQzQla780mQxLLU2GJC6xxxxxxxxxx';
$secretKey = 'b0GMH2c2NXWKxPhy7xxxxxxxxxxxx';
$region = 'ap-guangzhou';
$bucket = 'overtrue-123456789';

$adapter = new CosAdapter($secretId, $secretKey, $bucket, $region);
$config = [
'region' => 'ap-guangzhou',
'credentials' => [
'appId' => 1234567889, // 域名中数字部分
'secretId' => 'AKIDS5jNr5NNygGxxxxxxxxxxxxxxxxxx',
'secretKey' => 'NfszEWmyDqGmao0a4XS8wxxxxxxxxxxxx',
],
'bucket' => 'test',
'timeout' => 60,
'connect_timeout' => 60,
'cdn' => '您的 CDN 域名',
'scheme' => 'https',
'read_from_cdn' => false,
];

$adapter = new CosAdapter($config);

$flysystem = new League\Flysystem\Filesystem($adapter);

Expand Down
17 changes: 5 additions & 12 deletions src/CosAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,11 @@ class CosAdapter extends AbstractAdapter implements CanOverwriteFiles
/**
* CosAdapter constructor.
*
* @param string $secretId
* @param string $secretKey
* @param string $bucket
* @param string $region
* @param array $optional
*/
public function __construct($secretId, $secretKey, $bucket, $region, array $optional = [])
{
$this->config = array_merge(
\compact('region', 'bucket'), [
'credentials' => \compact('secretId', 'secretKey'),
], $optional);
* @param array $config
*/
public function __construct(array $config = [])
{
$this->config = $config;

$this->setPathPrefix($this->config['cdn'] ?? '');
}
Expand Down

0 comments on commit 1126c9f

Please sign in to comment.