Skip to content

Commit 19534f2

Browse files
committed
backup uphost
1 parent e5bf645 commit 19534f2

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Qiniu/Storage/ResumeUploader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ final class ResumeUploader
2424
private $contexts;
2525
private $host;
2626
private $currentUrl;
27+
private $config;
2728

2829
/**
2930
* 上传二进制流到七牛
@@ -52,6 +53,7 @@ public function __construct(
5253
$this->size = $size;
5354
$this->params = $params;
5455
$this->mime = $mime;
56+
$this->config = $config;
5557
$this->host = $config::$upHost;
5658
$this->contexts = array();
5759
}
@@ -77,7 +79,7 @@ public function upload()
7779
$ret = $response->json();
7880
}
7981
if ($response->statusCode < 0) {
80-
$this->host = $config::$upHostBackup;
82+
$this->host = $this->config::$upHostBackup;
8183
}
8284
if ($response->needRetry() || !isset($ret['crc32']) || $crc != $ret['crc32']) {
8385
$response = $this->makeBlock($data, $blockSize);

tests/Qiniu/Tests/ResumeUpTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
use Qiniu\Storage\ResumeUploader;
55
use Qiniu\Storage\UploadManager;
6+
use Qiniu\Zone;
7+
use Qiniu\Config;
68

79
class ResumeUpTest extends \PHPUnit_Framework_TestCase
810
{
@@ -29,6 +31,20 @@ public function test4ML()
2931
unlink($tempFile);
3032
}
3133

34+
public function test4ML2()
35+
{
36+
$key = 'resumePutFile4ML';
37+
$zone = new Zone('http://up.fake.com', 'http://up.qiniu.com');
38+
$cfg = new Config($zone);
39+
$upManager = new UploadManager($cfg);
40+
$token = $this->auth->uploadToken($this->bucketName, $key);
41+
$tempFile = qiniuTempFile(4*1024*1024+10);
42+
list($ret, $error) = $upManager->putFile($token, $key, $tempFile);
43+
$this->assertNull($error);
44+
$this->assertNotNull($ret['hash']);
45+
unlink($tempFile);
46+
}
47+
3248
// public function test8M()
3349
// {
3450
// $key = 'resumePutFile8M';

0 commit comments

Comments
 (0)