Esempio n. 1
0
 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));
     }
 }
Esempio n. 2
0
 public static function assertObjectKey($key)
 {
     if (!self::validObjectKey($key)) {
         throw new \InvalidArgumentException(ResourceManager::getInstance()->getString('ObjectKeyInvalid'));
     }
 }
Esempio n. 3
0
 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);
 }