/**
  * 解析LoggingConfig数据
  *
  * @return LoggingConfig
  */
 protected function parseDataFromResponse()
 {
     $content = $this->rawResponse->body;
     $config = new LoggingConfig();
     $config->parseFromXml($content);
     return $config;
 }
 public function testBucket()
 {
     $loggingConfig = new LoggingConfig($this->bucket, 'prefix');
     try {
         $this->ossClient->putBucketLogging($this->bucket, $this->bucket, 'prefix');
     } catch (Exception $e) {
         var_dump($e->getMessage());
         $this->assertTrue(false);
     }
     try {
         sleep(2);
         $loggingConfig2 = $this->ossClient->getBucketLogging($this->bucket);
         $this->assertEquals($loggingConfig->serializeToXml(), $loggingConfig2->serializeToXml());
     } catch (Exception $e) {
         $this->assertTrue(false);
     }
     try {
         $this->ossClient->deleteBucketLogging($this->bucket);
     } catch (Exception $e) {
         $this->assertTrue(false);
     }
     try {
         sleep(3);
         $loggingConfig3 = $this->ossClient->getBucketLogging($this->bucket);
         $this->assertNotEquals($loggingConfig->serializeToXml(), $loggingConfig3->serializeToXml());
     } catch (Exception $e) {
         $this->assertTrue(false);
     }
 }
Esempio n. 3
0
 /**
  * 开启Bucket访问日志记录功能,只有Bucket的所有者才能更改
  *
  * @param string $bucket       bucket名称
  * @param string $targetBucket 日志文件存放的bucket
  * @param string $targetPrefix 日志的文件前缀
  * @param array  $options      可以为空
  *
  * @throws Exception
  * @return null
  */
 public function putBucketLogging($bucket, $targetBucket, $targetPrefix, $options = null)
 {
     $this->precheckCommon($bucket, null, $options, false);
     $this->precheckBucket($targetBucket, 'targetbucket is not allowed empty');
     $options[self::OSS_BUCKET] = $bucket;
     $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
     $options[self::OSS_OBJECT] = '/';
     $options[self::OSS_SUB_RESOURCE] = 'logging';
     $options[self::OSS_CONTENT_TYPE] = 'application/xml';
     $loggingConfig = new LoggingConfig($targetBucket, $targetPrefix);
     $options[self::OSS_CONTENT] = $loggingConfig->serializeToXml();
     $response = $this->auth($options);
     $result = new PutSetDeleteResult($response);
     return $result->getData();
 }
 public function testFailedConstruct()
 {
     $loggingConfig = new LoggingConfig('TargetBucket', null);
     $this->assertEquals($this->cleanXml($this->nullXml), $this->cleanXml($loggingConfig->serializeToXml()));
 }