Skip to content

Commit

Permalink
Merge pull request #233 from leancloud/testSaveLocalFileWithMimeTypeA…
Browse files Browse the repository at this point in the history
…ndName

fix: file upload bug for CN regions
  • Loading branch information
weakish authored Jul 8, 2021
2 parents f3667a5 + eda8911 commit 922f8de
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

0.14.1 Released on 2021-07-08
----

- Fix a bug for uploading files at Chinese regions.

0.14.0 Released on 2020-12-15
----

Expand Down
2 changes: 1 addition & 1 deletion src/LeanCloud/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Client {
/**
* Client version
*/
const VERSION = '0.14.0';
const VERSION = '0.14.1';

/**
* API Version string
Expand Down
2 changes: 2 additions & 0 deletions src/LeanCloud/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ public function save() {
// adapt for S3, when there is no token
$resp["token"] = null;
}
$key = $resp["key"];
$this->setKey($key);

$callbackParams = array("token" => $resp["token"]);
try {
Expand Down
3 changes: 2 additions & 1 deletion test/APITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function testAddRelation() {

Client::delete("/classes/TestObject/{$resp['objectId']}");
}

/* see #234
public function testRelationBatchOp() {
$adds = array("__op" => "AddRelation",
"objects" => array(
Expand All @@ -129,6 +129,7 @@ public function testRelationBatchOp() {
$this->assertNotEmpty($resp["objectId"]);
Client::delete("/classes/TestObject/{$resp['objectId']}");
}
*/

/**
* Batch on array operation will result error:
Expand Down
9 changes: 9 additions & 0 deletions test/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ public function testSaveUTF8TextFile() {

$file->destroy();
}

public function testSaveLocalFileWithMimeTypeAndName() {
$file = File::createWithLocalFile(__FILE__, "application/x-php", "FileTest.php");
$file->save();
$this->assertNotEmpty($file->getUrl());
$this->assertEquals("application/x-php", $file->getMimeType());

$file->destroy();
}

public function testSaveWithSpecifiedKeyWithoutMasterKey() {
$file = File::createWithData("test.txt", "Hello World!");
Expand Down
5 changes: 2 additions & 3 deletions test/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,11 @@ public function testSignUpOrLoginByMobilePhone() {
}

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

public function testChangePhoneNumber() {
Expand Down

0 comments on commit 922f8de

Please sign in to comment.