Skip to content

Commit

Permalink
update GetFederationToken
Browse files Browse the repository at this point in the history
  • Loading branch information
freyo committed Jan 8, 2019
1 parent c3510ec commit e80ff54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/Adapter.php
Expand Up @@ -57,21 +57,25 @@ public function __construct(Client $client, array $config)

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

/**
* @return string
*/
public function getBucketWithAppId()
{
return $this->getBucket().'-'.$this->getAppId();
}

/**
* @return string
*/
public function getBucket()
{
return $this->config['bucket'];
return preg_replace(
"/-{$this->getAppId()}$/",
'',
$this->config['bucket']
);
}

/**
Expand Down
11 changes: 6 additions & 5 deletions src/Plugins/GetFederationToken.php
Expand Up @@ -2,6 +2,7 @@

namespace Freyo\Flysystem\QcloudCOSv5\Plugins;

use Closure;
use League\Flysystem\Plugin\AbstractPlugin;

class GetFederationToken extends AbstractPlugin
Expand All @@ -19,14 +20,14 @@ public function getMethod()
/**
* @param string $path
* @param int $seconds
* @param callable $customPolicy
* @param Closure $customPolicy
* @param string $name
*
* @return bool|array
*/
public function handle($path = '', $seconds = 7200, callable $customPolicy = null, $name = 'cos')
public function handle($path = '', $seconds = 7200, Closure $customPolicy = null, $name = 'cos')
{
$policy = is_callable($customPolicy)
$policy = !is_null($customPolicy)
? $this->getCustomPolicy($customPolicy, $path)
: $this->getPolicy($path);

Expand All @@ -40,12 +41,12 @@ public function handle($path = '', $seconds = 7200, callable $customPolicy = nul
}

/**
* @param callable $callable
* @param Closure $callable
* @param $path
*
* @return string
*/
protected function getCustomPolicy(callable $callable, $path)
protected function getCustomPolicy(Closure $callable, $path)
{
$policy = call_user_func($callable, $path, $this->getConfig());

Expand Down

0 comments on commit e80ff54

Please sign in to comment.