Skip to content

Commit 029b544

Browse files
committed
Merge pull request #41 from dtynn/wanglin/up-resumable
Wanglin/up resumable
2 parents e5425bb + a3b83f9 commit 029b544

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

qiniu/resumable_io.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ function Qiniu_Rio_Mkblock($self, $host, $reader, $size) // => ($blkputRet, $err
5959
return Qiniu_Client_CallWithForm($self, $url, $body, 'application/octet-stream');
6060
}
6161

62+
6263
function Qiniu_Rio_Mkfile($self, $host, $key, $fsize, $extra) // => ($putRet, $err)
6364
{
64-
$entry = $extra->Bucket . ':' . $key;
65-
$url = $host . '/rs-mkfile/' . Qiniu_Encode($entry) . '/fsize/' . $fsize;
66-
65+
$url = $host . '/mkfile/' . $fsize;
66+
if ($key !== null) {
67+
$url .= '/key/' . Qiniu_Encode($key);
68+
}
6769
if (!empty($extra->MimeType)) {
6870
$url .= '/mimeType/' . Qiniu_Encode($extra->MimeType);
6971
}
@@ -74,7 +76,7 @@ function Qiniu_Rio_Mkfile($self, $host, $key, $fsize, $extra) // => ($putRet, $e
7476
}
7577
$body = implode(',', $ctxs);
7678

77-
return Qiniu_Client_CallWithForm($self, $url, $body, 'text/plain');
79+
return Qiniu_Client_CallWithForm($self, $url, $body, 'application/octet-stream');
7880
}
7981

8082
// ----------------------------------------------------------
@@ -107,22 +109,21 @@ function Qiniu_Rio_Put($upToken, $key, $body, $fsize, $putExtra) // => ($putRet,
107109
$self = new Qiniu_Rio_UploadClient($upToken);
108110

109111
$progresses = array();
110-
$host = $QINIU_UP_HOST;
111112
$uploaded = 0;
112113
while ($uploaded < $fsize) {
113114
if ($fsize < $uploaded + QINIU_RIO_BLOCK_SIZE) {
114115
$bsize = $fsize - $uploaded;
115116
} else {
116117
$bsize = QINIU_RIO_BLOCK_SIZE;
117118
}
118-
list($blkputRet, $err) = Qiniu_Rio_Mkblock($self, $host, $body, $bsize);
119+
list($blkputRet, $err) = Qiniu_Rio_Mkblock($self, $QINIU_UP_HOST, $body, $bsize);
119120
$host = $blkputRet['host'];
120121
$uploaded += $bsize;
121122
$progresses []= $blkputRet;
122123
}
123124

124125
$putExtra->Progresses = $progresses;
125-
return Qiniu_Rio_Mkfile($self, $host, $key, $fsize, $putExtra);
126+
return Qiniu_Rio_Mkfile($self, $QINIU_UP_HOST, $key, $fsize, $putExtra);
126127
}
127128

128129
function Qiniu_Rio_PutFile($upToken, $key, $localFile, $putExtra) // => ($putRet, $err)

0 commit comments

Comments
 (0)