Ejemplo n.º 1
0
    public function testCreateDeleteObjectsXmlBody()
    {
        $xml = <<<BBBB
<?xml version="1.0" encoding="utf-8"?><Delete><Quiet>true</Quiet><Object><Key>obj1</Key></Object></Delete>
BBBB;
        $a = array('obj1');
        $this->assertEquals($xml, $this->cleanXml(OssUtil::createDeleteObjectsXmlBody($a, 'true')));
    }
Ejemplo n.º 2
0
 /**
  * 删除同一个Bucket中的多个Object
  *
  * @param string $bucket bucket名称
  * @param array $objects object列表
  * @param array $options
  * @return ResponseCore
  * @throws null
  */
 public function deleteObjects($bucket, $objects, $options = null)
 {
     $this->precheckCommon($bucket, NULL, $options, false);
     if (!is_array($objects) || !$objects) {
         throw new OssException('objects must be array');
     }
     $options[self::OSS_METHOD] = self::OSS_HTTP_POST;
     $options[self::OSS_BUCKET] = $bucket;
     $options[self::OSS_OBJECT] = '/';
     $options[self::OSS_SUB_RESOURCE] = 'delete';
     $options[self::OSS_CONTENT_TYPE] = 'application/xml';
     $quiet = 'false';
     if (isset($options['quiet'])) {
         if (is_bool($options['quiet'])) {
             //Boolean
             $quiet = $options['quiet'] ? 'true' : 'false';
         } elseif (is_string($options['quiet'])) {
             // string
             $quiet = $options['quiet'] === 'true' ? 'true' : 'false';
         }
     }
     $xmlBody = OssUtil::createDeleteObjectsXmlBody($objects, $quiet);
     $options[self::OSS_CONTENT] = $xmlBody;
     $response = $this->auth($options);
     $result = new DeleteObjectsResult($response);
     return $result->getData();
 }