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(Util::createDeleteObjectsXmlBody($a, 'true'))); }
/** * 删除同一个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 Exception('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 = Util::createDeleteObjectsXmlBody($objects, $quiet); $options[self::OSS_CONTENT] = $xmlBody; $response = $this->auth($options); $result = new PutSetDeleteResult($response); return $result->getData(); }