Skip to content

Use getHeaderLine method to get ETag header #346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/MultipartUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MultipartUpload {
const MIN_PART_SIZE = 1048576;
const MAX_PART_SIZE = 5368709120;
const DEFAULT_PART_SIZE = 5242880;
const MAX_PARTS = 10000;
const MAX_PARTS = 10000;

private $client;
private $options;
Expand Down Expand Up @@ -89,7 +89,7 @@ public function uploadParts($uploadId) {
'Body' => $body,
'ContentMD5' => $this->needMd5
);
if ($this->needMd5 == false) {
if (!$this->needMd5) {
unset($params["ContentMD5"]);
}
if (!isset($this->parts[$partNumber])) {
Expand All @@ -106,15 +106,8 @@ public function uploadParts($uploadId) {
$index = $index + 1;
$partNumber = $this->partNumberList[$index]['PartNumber'];
$partSize = $this->partNumberList[$index]['PartSize'];

//兼容两种写法,防止index为undefined
if (array_key_exists('etag', $response->getHeaders())) {
$etag = $response->getHeaders()["etag"][0];
}

if (array_key_exists('ETag', $response->getHeaders())) {
$etag = $response->getHeaders()["ETag"][0];
}
/** @var \GuzzleHttp\Psr7\Response $response */
$etag = $response->getHeaderLine('ETag');
$part = array('PartNumber' => $partNumber, 'ETag' => $etag);
$this->parts[$partNumber] = $part;
$this->uploadedSize += $partSize;
Expand Down