public function handle(HttpResponse $response) { if ($response->getStatusCode() == 404) { $response->close(); throw OSSExceptionFactory::factory()->create(OSSErrorCode::NO_SUCH_KEY, ResourceManager::getInstance()->getString('NoSuchKey'), $response->getHeader(OSSHeaders::OSS_HEADER_REQUEST_ID)); } }
public static function assertObjectKey($key) { if (!self::validObjectKey($key)) { throw new \InvalidArgumentException(ResourceManager::getInstance()->getString('ObjectKeyInvalid')); } }
protected function __construct(array $config) { // Merge config with default config $config = array_merge(ResourceManager::getInstance()->getDefaultOptions(__DIR__), $config); // To ensure contains import args AssertUtils::assertSet(array(OSSOptions::ENDPOINT, OSSOptions::ACCESS_KEY_ID, OSSOptions::ACCESS_KEY_SECRET), $config); // Config client $this->endpoint = $config[OSSOptions::ENDPOINT]; $this->credentials = array(OSSOptions::ACCESS_KEY_ID => $config[OSSOptions::ACCESS_KEY_ID], OSSOptions::ACCESS_KEY_SECRET => $config[OSSOptions::ACCESS_KEY_SECRET]); // Creat service client $this->serviceClient = ServiceClientFactory::factory()->createService($config); }