Skip to content
Closed
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
4 changes: 3 additions & 1 deletion src/Qiniu/Storage/ResumeUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ final class ResumeUploader
private $contexts;
private $host;
private $currentUrl;
private $config;

/**
* 上传二进制流到七牛
Expand Down Expand Up @@ -52,6 +53,7 @@ public function __construct(
$this->size = $size;
$this->params = $params;
$this->mime = $mime;
$this->config = $config;
$this->host = $config::$upHost;
$this->contexts = array();
}
Expand All @@ -77,7 +79,7 @@ public function upload()
$ret = $response->json();
}
if ($response->statusCode < 0) {
$this->host = $config::$upHostBackup;
$this->host = $this->config::$upHostBackup;
}
if ($response->needRetry() || !isset($ret['crc32']) || $crc != $ret['crc32']) {
$response = $this->makeBlock($data, $blockSize);
Expand Down
16 changes: 16 additions & 0 deletions tests/Qiniu/Tests/ResumeUpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use Qiniu\Storage\ResumeUploader;
use Qiniu\Storage\UploadManager;
use Qiniu\Zone;
use Qiniu\Config;

class ResumeUpTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -29,6 +31,20 @@ public function test4ML()
unlink($tempFile);
}

public function test4ML2()
{
$key = 'resumePutFile4ML';
$zone = new Zone('http://up.fake.com', 'http://up.qiniu.com');
$cfg = new Config($zone);
$upManager = new UploadManager($cfg);
$token = $this->auth->uploadToken($this->bucketName, $key);
$tempFile = qiniuTempFile(4*1024*1024+10);
list($ret, $error) = $upManager->putFile($token, $key, $tempFile);
$this->assertNull($error);
$this->assertNotNull($ret['hash']);
unlink($tempFile);
}

// public function test8M()
// {
// $key = 'resumePutFile8M';
Expand Down