public function testParseValidHeader() { $response = new ResponseCore($this->validHeader, "", 200); $result = new UploadPartResult($response); $eTag = $result->getData(); $this->assertEquals('7265F4D211B56873A381D321F586E4A9', $eTag); }
/** * 从一个已存在的Object中拷贝数据来上传一个Part * * @param string $fromBucket 源bucket名称 * @param string $fromObject 源object名称 * @param string $toBucket 目标bucket名称 * @param string $toObject 目标object名称 * @param int $partNumber 分块上传的块id * @param string $uploadId 初始化multipart upload返回的uploadid * @param array $options Key-Value数组 * @return null * @throws OssException */ public function uploadPartCopy($fromBucket, $fromObject, $toBucket, $toObject, $partNumber, $uploadId, $options = NULL) { $this->precheckCommon($fromBucket, $fromObject, $options); $this->precheckCommon($toBucket, $toObject, $options); //如果没有设置$options['isFullCopy'],则需要强制判断copy的起止位置 $start_range = "0"; if (isset($options['start'])) { $start_range = $options['start']; } $end_range = ""; if (isset($options['end'])) { $end_range = $options['end']; } $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; $options[self::OSS_BUCKET] = $toBucket; $options[self::OSS_OBJECT] = $toObject; $options[self::OSS_PART_NUM] = $partNumber; $options[self::OSS_UPLOAD_ID] = $uploadId; if (!isset($options[self::OSS_HEADERS])) { $options[self::OSS_HEADERS] = array(); } $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = '/' . $fromBucket . '/' . $fromObject; $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE_RANGE] = "bytes=" . $start_range . "-" . $end_range; $response = $this->auth($options); $result = new UploadPartResult($response); return $result->getData(); }