示例#1
0
 /**
  * 在将所有数据Part都上传完成后,调用此接口完成本次分块上传
  *
  * @param string $bucket    Bucket名称
  * @param string $object    Object名称
  * @param string $uploadId  uploadId
  * @param array  $listParts array( array("PartNumber"=> int, "ETag"=>string))
  * @param array  $options   Key-Value数组
  *
  * @throws Exception
  * @return null
  */
 public function completeMultipartUpload($bucket, $object, $uploadId, $listParts, $options = null)
 {
     $this->precheckCommon($bucket, $object, $options);
     $options[self::OSS_METHOD] = self::OSS_HTTP_POST;
     $options[self::OSS_BUCKET] = $bucket;
     $options[self::OSS_OBJECT] = $object;
     $options[self::OSS_UPLOAD_ID] = $uploadId;
     $options[self::OSS_CONTENT_TYPE] = 'application/xml';
     if (!is_array($listParts)) {
         throw new Exception("listParts must be array type");
     }
     $options[self::OSS_CONTENT] = Util::createCompleteMultipartUploadXmlBody($listParts);
     $response = $this->auth($options);
     $result = new PutSetDeleteResult($response);
     return $result->getData();
 }
示例#2
0
    public function testCreateCompleteMultipartUploadXmlBody()
    {
        $xml = <<<BBBB
<?xml version="1.0" encoding="utf-8"?><CompleteMultipartUpload><Part><PartNumber>2</PartNumber><ETag>xx</ETag></Part></CompleteMultipartUpload>
BBBB;
        $a = array(array("PartNumber" => 2, "ETag" => "xx"));
        $this->assertEquals($this->cleanXml(Util::createCompleteMultipartUploadXmlBody($a)), $xml);
    }