Skip to content

Commit 922f8de

Browse files
authored
Merge pull request #233 from leancloud/testSaveLocalFileWithMimeTypeAndName
fix: file upload bug for CN regions
2 parents f3667a5 + eda8911 commit 922f8de

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
0.14.1 Released on 2021-07-08
3+
----
4+
5+
- Fix a bug for uploading files at Chinese regions.
6+
27
0.14.0 Released on 2020-12-15
38
----
49

src/LeanCloud/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Client {
2424
/**
2525
* Client version
2626
*/
27-
const VERSION = '0.14.0';
27+
const VERSION = '0.14.1';
2828

2929
/**
3030
* API Version string

src/LeanCloud/File.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ public function save() {
385385
// adapt for S3, when there is no token
386386
$resp["token"] = null;
387387
}
388+
$key = $resp["key"];
389+
$this->setKey($key);
388390

389391
$callbackParams = array("token" => $resp["token"]);
390392
try {

test/APITest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function testAddRelation() {
110110

111111
Client::delete("/classes/TestObject/{$resp['objectId']}");
112112
}
113-
113+
/* see #234
114114
public function testRelationBatchOp() {
115115
$adds = array("__op" => "AddRelation",
116116
"objects" => array(
@@ -129,6 +129,7 @@ public function testRelationBatchOp() {
129129
$this->assertNotEmpty($resp["objectId"]);
130130
Client::delete("/classes/TestObject/{$resp['objectId']}");
131131
}
132+
*/
132133

133134
/**
134135
* Batch on array operation will result error:

test/FileTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ public function testSaveUTF8TextFile() {
6363

6464
$file->destroy();
6565
}
66+
67+
public function testSaveLocalFileWithMimeTypeAndName() {
68+
$file = File::createWithLocalFile(__FILE__, "application/x-php", "FileTest.php");
69+
$file->save();
70+
$this->assertNotEmpty($file->getUrl());
71+
$this->assertEquals("application/x-php", $file->getMimeType());
72+
73+
$file->destroy();
74+
}
6675

6776
public function testSaveWithSpecifiedKeyWithoutMasterKey() {
6877
$file = File::createWithData("test.txt", "Hello World!");

test/UserTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,11 @@ public function testSignUpOrLoginByMobilePhone() {
182182
}
183183

184184
public function testRequestChangePhoneNumber() {
185-
$this->setExpectedException("LeanCloud\CloudException", null, 600); // invalid signature
186-
$this->setExpectedException("LeanCloud\CloudException", null, 605); // SMS template/signature not verified.
187185
// Remember to create this user before hand.
188186
User::logIn("php_test_change_phone_number", "blabla");
187+
// Uncomment the follow lines when manually running the test.
189188
// phone number is from https://www.yinsiduanxin.com
190-
User::requestChangePhoneNumber("+8616533875941");
189+
// User::requestChangePhoneNumber("+8616533875941");
191190
}
192191

193192
public function testChangePhoneNumber() {

0 commit comments

Comments
 (0)