Skip to content

Commit 20962ce

Browse files
committed
Merge pull request #22 from qiniu/develop
Release v6.1.0
2 parents f50f1be + 35143b1 commit 20962ce

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## CHANGE LOG
22

3+
### v6.1.0
4+
5+
2013-07-04 issue [#22](https://github.com/qiniu/api/pull/22)
6+
7+
- hotfix: 修复上传的时候 key 中不能出现 '/' 的错误
8+
9+
310
### v6.0.2
411

512
2013-07-04 issue [#20](https://github.com/qiniu/api/pull/20)

qiniu/conf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$QINIU_UP_HOST = 'http://up.qbox.me';
3+
$QINIU_UP_HOST = 'http://up.qiniu.com';
44
$QINIU_RS_HOST = 'http://rs.qbox.me';
55
$QINIU_RSF_HOST = 'http://rsf.qbox.me';
66

qiniu/http.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,29 +251,37 @@ function Qiniu_Build_MultipartForm($fields, $files) // => ($contentType, $body)
251251
$data = array();
252252
$mimeBoundary = md5(microtime());
253253

254-
foreach ($fields as $name => $val){
254+
foreach ($fields as $name => $val) {
255255
array_push($data, '--' . $mimeBoundary);
256-
array_push($data, "Content-Disposition: form-data; name=$name");
256+
array_push($data, "Content-Disposition: form-data; name=\"$name\"");
257257
array_push($data, '');
258258
array_push($data, $val);
259259
}
260260

261261
foreach ($files as $file) {
262262
array_push($data, '--' . $mimeBoundary);
263-
list($name, $fileName, $fileCxt) = $file;
264-
array_push($data, "Content-Disposition: form-data; name=$name; filename=$fileName");
263+
list($name, $fileName, $fileBody) = $file;
264+
$fileName = Qiniu_escapeQuotes($fileName);
265+
array_push($data, "Content-Disposition: form-data; name=\"$name\"; filename=\"$fileName\"");
265266
array_push($data, 'Content-Type: application/octet-stream');
266267
array_push($data, '');
267-
array_push($data, $fileCxt);
268+
array_push($data, $fileBody);
268269
}
269270

270-
array_push($data, '--' . $mimeBoundary);
271+
array_push($data, '--' . $mimeBoundary . '--');
271272
array_push($data, '');
272273

273274
$body = implode("\r\n", $data);
274275
$contentType = 'multipart/form-data; boundary=' . $mimeBoundary;
275276
return array($contentType, $body);
276277
}
277278

279+
function Qiniu_escapeQuotes($str)
280+
{
281+
$find = array("\\", "\"");
282+
$replace = array("\\\\", "\\\"");
283+
return str_replace($find, $replace, $str);
284+
}
285+
278286
// --------------------------------------------------------------------------------
279287

tests/RsUtilsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function setUp()
1616

1717
public function testPutFile()
1818
{
19-
$key = 'testPutFile' . getTid();
19+
$key = 'tmp/testPutFile' . getTid();
2020
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
2121

2222
$putExtra = new Qiniu_PutExtra();
@@ -36,7 +36,7 @@ public function testPutFile()
3636

3737
public function testPut()
3838
{
39-
$key = 'testPut' . getTid();
39+
$key = 'tmp/testPut' . getTid();
4040
$err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
4141

4242
list($ret, $err) = Qiniu_RS_Put($this->client, $this->bucket, $key, "hello world!", null);

0 commit comments

Comments
 (0)