Skip to content
Open
Show file tree
Hide file tree
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
37 changes: 21 additions & 16 deletions src/Upyun/Api/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,27 @@ public function upload($path, $stream, $params)
'timeout' => $this->config->timeout,
]);

$response = $client->request($method, $this->endpoint, array(
'multipart' => array(
array(
'name' => 'policy',
'contents' => $policy,
),
array(
'name' => 'authorization',
'contents' => $signature,
),
array(
'name' => 'file',
'contents' => $stream,
for ($i = 0; $i < $this->config->retry; $i++) {
$response = $client->request($method, $this->endpoint, array(
'multipart' => array(
array(
'name' => 'policy',
'contents' => $policy,
),
array(
'name' => 'authorization',
'contents' => $signature,
),
array(
'name' => 'file',
'contents' => $stream,
)
)
)
));
return $response->getStatusCode() === 200;
));
if ($response->getStatusCode() == 200) {
return true;
}
}
return false;
}
}
5 changes: 5 additions & 0 deletions src/Upyun/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class Config
*/
public $sizeBoundary = 31457280;

/**
* @var int 支持 form 上传时重试
*/
public $retry = 1;

/**
* @var int 并行式断点续传的并发数
*/
Expand Down