From 3c4ee2310be54c42e287fb2e18886a501e615488 Mon Sep 17 00:00:00 2001 From: hzqiujiansong Date: Thu, 11 Aug 2016 20:23:41 +0800 Subject: [PATCH] fix --- samples/Bucket.php | 10 +++++----- samples/Common.php | 6 +++--- samples/MultipartUpload.php | 18 ++++++++--------- samples/Object.php | 10 +++++----- samples/Signature.php | 2 +- src/NOS/NOSClient.php | 2 +- tests/NOS/Tests/Common.php | 6 +++--- tests/NOS/Tests/NosClientBucketTest.php | 6 +++--- .../Tests/NosClientMultipartUploadTest.php | 14 ++++++------- tests/NOS/Tests/NosClientObjectTest.php | 14 ++++++------- tests/NOS/Tests/NosClientSignatureTest.php | 2 +- tests/NOS/Tests/NosClientTest.php | 20 +++++++++---------- tests/NOS/Tests/TestNosClientBase.php | 2 +- 13 files changed, 56 insertions(+), 56 deletions(-) diff --git a/samples/Bucket.php b/samples/Bucket.php index 150e54e..e032016 100644 --- a/samples/Bucket.php +++ b/samples/Bucket.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/Common.php'; -use NOS\NOSClient; +use NOS\NosClient; use NOS\Core\NosException; $bucket = Common::getTestBucketName(); @@ -15,7 +15,7 @@ if(!$exist) { - $nosClient->createBucket($bucket, NOSClient::NOS_ACL_TYPE_PRIVATE); + $nosClient->createBucket($bucket, NosClient::NOS_ACL_TYPE_PRIVATE); Common::println("bucket $bucket created"); } @@ -24,7 +24,7 @@ $bucketListInfo = $nosClient->listBuckets(); -$nosClient->putBucketAcl($bucket, NOSClient::NOS_ACL_TYPE_PUBLIC_READ); +$nosClient->putBucketAcl($bucket, NosClient::NOS_ACL_TYPE_PUBLIC_READ); Common::println("bucket $bucket acl put"); $acl = $nosClient->getBucketAcl($bucket); @@ -45,7 +45,7 @@ function createBucket($nosClient, $bucket) { try { - $nosClient->createBucket($bucket, NOSClient::NOS_ACL_TYPE_PUBLIC_READ); + $nosClient->createBucket($bucket, NosClient::NOS_ACL_TYPE_PUBLIC_READ); } catch (NosException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); @@ -86,7 +86,7 @@ function deleteBucket($nosClient, $bucket) function putBucketAcl($nosClient, $bucket) { - $acl = NOSClient::NOS_ACL_TYPE_PUBLIC_READ; + $acl = NosClient::NOS_ACL_TYPE_PUBLIC_READ; try { $nosClient->putBucketAcl($bucket, $acl); } catch (NosException $e) { diff --git a/samples/Common.php b/samples/Common.php index dc3d59e..4e7697b 100644 --- a/samples/Common.php +++ b/samples/Common.php @@ -7,7 +7,7 @@ } require_once __DIR__ . '/Config.php'; -use NOS\NOSClient; +use NOS\NosClient; use NOS\Core\NosException; class Common @@ -24,7 +24,7 @@ class Common public static function getNosClient() { try { - $nosClient = new NOSClient(self::accessKey, self::accessKeySecret, self::endPoint); + $nosClient = new NosClient(self::accessKey, self::accessKeySecret, self::endPoint); } catch (NosException $e) { printf(__FUNCTION__ . "creating NosClient instance: FAILED\n"); printf($e->getMessage() . "\n"); @@ -53,7 +53,7 @@ public static function createBucket() if ($exist) { return; } - $acl = NOSClient::NOS_ACL_TYPE_PUBLIC_READ; + $acl = NosClient::NOS_ACL_TYPE_PUBLIC_READ; try { $nosClient->createBucket(self::bucket, $acl); } catch (NosException $e) { diff --git a/samples/MultipartUpload.php b/samples/MultipartUpload.php index f514f9c..bcf6db3 100644 --- a/samples/MultipartUpload.php +++ b/samples/MultipartUpload.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/Common.php'; -use NOS\NOSClient; +use NOS\NosClient; use NOS\Core\NosUtil; use NOS\Core\NosException; @@ -66,18 +66,18 @@ function putObjectByRawApis($nosClient, $bucket) $uploadPosition = 0; $isCheckMd5 = true; foreach ($pieces as $i => $piece) { - $fromPos = $uploadPosition + (integer)$piece[NOSClient::NOS_SEEK_TO]; - $toPos = (integer)$piece[NOSClient::NOS_LENGTH] + $fromPos - 1; + $fromPos = $uploadPosition + (integer)$piece[NosClient::NOS_SEEK_TO]; + $toPos = (integer)$piece[NosClient::NOS_LENGTH] + $fromPos - 1; $upOptions = array( - NOSClient::NOS_FILE_UPLOAD => $uploadFile, - NOSClient::NOS_PART_NUM => ($i + 1), - NOSClient::NOS_SEEK_TO => $fromPos, - NOSClient::NOS_LENGTH => $toPos - $fromPos + 1, - NOSClient::NOS_CHECK_MD5 => $isCheckMd5, + NosClient::NOS_FILE_UPLOAD => $uploadFile, + NosClient::NOS_PART_NUM => ($i + 1), + NosClient::NOS_SEEK_TO => $fromPos, + NosClient::NOS_LENGTH => $toPos - $fromPos + 1, + NosClient::NOS_CHECK_MD5 => $isCheckMd5, ); if ($isCheckMd5) { $contentMd5 = NosUtil::getMd5SumForFile($uploadFile, $fromPos, $toPos); - $upOptions[NOSClient::NOS_CONTENT_MD5] = $contentMd5; + $upOptions[NosClient::NOS_CONTENT_MD5] = $contentMd5; } //2. 将每一分片上传到nos try { diff --git a/samples/Object.php b/samples/Object.php index a34a753..a337453 100644 --- a/samples/Object.php +++ b/samples/Object.php @@ -1,7 +1,7 @@ "./c.file.localcopy", + NosClient::NOS_FILE_DOWNLOAD => "./c.file.localcopy", ); $nosClient->getObject($bucket, "c.file", $options); Common::println("b.file is fetched to the local file: c.file.localcopy"); @@ -92,8 +92,8 @@ function uploadFile($nosClient, $bucket) $options = array(); try { - $options[NOSClient::NOS_HEADERS]['Cache-Control'] = 'max-age=60'; - $options[NOSClient::NOS_HEADERS]['Content-Disposition'] = 'attachment; filename="xxxxxx"'; + $options[NosClient::NOS_HEADERS]['Cache-Control'] = 'max-age=60'; + $options[NosClient::NOS_HEADERS]['Content-Disposition'] = 'attachment; filename="xxxxxx"'; $nosClient->uploadFile($bucket, $object, $filePath, $options); } catch (NosException $e) { printf(__FUNCTION__ . ": FAILED\n"); @@ -200,7 +200,7 @@ function getObjectToLocalFile($nosClient, $bucket) $object = "nos-php-sdk-test/upload-test-object-name.txt"; $localfile = "upload-test-object-name.txt"; $options = array( - NOSClient::NOS_FILE_DOWNLOAD => $localfile, + NosClient::NOS_FILE_DOWNLOAD => $localfile, ); try { diff --git a/samples/Signature.php b/samples/Signature.php index c897473..f3145c3 100644 --- a/samples/Signature.php +++ b/samples/Signature.php @@ -4,7 +4,7 @@ use NOS\Http\RequestCore; use NOS\Http\ResponseCore; -use NOS\NOSClient; +use NOS\NosClient; use NOS\Core\NosException; $bucket = Common::getTestBucketName(); diff --git a/src/NOS/NOSClient.php b/src/NOS/NOSClient.php index a76423f..4f07185 100644 --- a/src/NOS/NOSClient.php +++ b/src/NOS/NOSClient.php @@ -31,7 +31,7 @@ * 用户通过NOSClient实例可以进行Object,MultipartUpload等操作,具体 * 的接口规则可以参考官方NOS API文档 */ -class NOSClient +class NosClient { /** diff --git a/tests/NOS/Tests/Common.php b/tests/NOS/Tests/Common.php index 3a00355..e4a4a78 100644 --- a/tests/NOS/Tests/Common.php +++ b/tests/NOS/Tests/Common.php @@ -3,7 +3,7 @@ require_once __DIR__ . '/../../../autoload.php'; -use NOS\NOSClient; +use NOS\NosClient; use NOS\Core\NosException; class Common @@ -16,7 +16,7 @@ class Common public static function getNosClient() { try { - $NosClient = new NOSClient( + $NosClient = new NosClient( getenv('NOS_ACCESS_KEY_ID'), getenv('NOS_ACCESS_KEY_SECRET'), getenv('NOS_ENDPOINT'), false); @@ -41,7 +41,7 @@ public static function createBucket() $nosClient = self::getNosClient(); if (is_null($nosClient)) exit(1); $bucket = self::getBucketName(); - $acl = NOSClient::NOS_ACL_TYPE_PUBLIC_READ; + $acl = NosClient::NOS_ACL_TYPE_PUBLIC_READ; try { $nosClient->createBucket($bucket, $acl); } catch (NosException $e) { diff --git a/tests/NOS/Tests/NosClientBucketTest.php b/tests/NOS/Tests/NosClientBucketTest.php index 82d870e..fd1d271 100644 --- a/tests/NOS/Tests/NosClientBucketTest.php +++ b/tests/NOS/Tests/NosClientBucketTest.php @@ -2,7 +2,7 @@ namespace NOS\Tests; use NOS\Core\NosException; -use NOS\NOSClient; +use NOS\NosClient; require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestNosClientBase.php'; class NosClientBucketTest extends TestNosClientBase @@ -36,9 +36,9 @@ public function testBucket() $bucketList = $bucketListInfo->getBucketList(); $this->assertTrue(is_array($bucketList)); $this->assertGreaterThan(0, count($bucketList)); - $this->nosClient->putBucketAcl($this->bucket, NOSClient::NOS_ACL_TYPE_PUBLIC_READ); + $this->nosClient->putBucketAcl($this->bucket, NosClient::NOS_ACL_TYPE_PUBLIC_READ); Common::waitMetaSync(); - $this->assertEquals($this->nosClient->getBucketAcl($this->bucket), NOSClient::NOS_ACL_TYPE_PUBLIC_READ); + $this->assertEquals($this->nosClient->getBucketAcl($this->bucket), NosClient::NOS_ACL_TYPE_PUBLIC_READ); //$this->nosClient->putBucketDuplication($this->bucket,NosClient::NOS_DUPLICATION_ENABLE); //Common::waitMetaSync(); diff --git a/tests/NOS/Tests/NosClientMultipartUploadTest.php b/tests/NOS/Tests/NosClientMultipartUploadTest.php index e5d728c..275ad04 100644 --- a/tests/NOS/Tests/NosClientMultipartUploadTest.php +++ b/tests/NOS/Tests/NosClientMultipartUploadTest.php @@ -3,7 +3,7 @@ use NOS\Core\NosException; use NOS\Core\NosUtil; -use NOS\NOSClient; +use NOS\NosClient; require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestNosClientBase.php'; @@ -17,8 +17,8 @@ public function testMultipartUploadBigFile() $object = 'multipart-bigfile-test.tmp'; try { - $this->nosClient->multiuploadFile($this->bucket, $object, $bigFileName, array(NOSClient::NOS_PART_SIZE => 1)); - $options = array(NOSClient::NOS_FILE_DOWNLOAD => $localFilename); + $this->nosClient->multiuploadFile($this->bucket, $object, $bigFileName, array(NosClient::NOS_PART_SIZE => 1)); + $options = array(NosClient::NOS_FILE_DOWNLOAD => $localFilename); $this->nosClient->getObject($this->bucket, $object, $options); $this->assertEquals(md5_file($bigFileName), md5_file($localFilename)); } catch (NosException $e) { @@ -48,8 +48,8 @@ public function testmultiUploadSuccess() $upload_parts = array(); NosUtil::generateFile($partFileName, 6 * 1024); $options = array(); - $options[NOSClient::NOS_FILE_UPLOAD] = $partFileName; - $options[NOSClient::NOS_PART_NUM] = $partId; + $options[NosClient::NOS_FILE_UPLOAD] = $partFileName; + $options[NosClient::NOS_PART_NUM] = $partId; $eTag = $this->nosClient->uploadPart($this->bucket,$object,$upload_id,$options); $upload_parts[] = array( 'PartNumber' => $partId, @@ -99,8 +99,8 @@ public function testAbortmultiUpload() $partId = 1; NosUtil::generateFile($partFileName, 6 * 1024); $options = array(); - $options[NOSClient::NOS_FILE_UPLOAD] = $partFileName; - $options[NOSClient::NOS_PART_NUM] = $partId; + $options[NosClient::NOS_FILE_UPLOAD] = $partFileName; + $options[NosClient::NOS_PART_NUM] = $partId; $this->nosClient->uploadPart($this->bucket,$object,$upload_id,$options); try { diff --git a/tests/NOS/Tests/NosClientObjectTest.php b/tests/NOS/Tests/NosClientObjectTest.php index 51e675d..2288a38 100644 --- a/tests/NOS/Tests/NosClientObjectTest.php +++ b/tests/NOS/Tests/NosClientObjectTest.php @@ -2,7 +2,7 @@ namespace NOS\Tests; use NOS\Core\NosException; -use NOS\NOSClient; +use NOS\NosClient; require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestNosClientBase.php'; class NosClientObjectTest extends TestNosClientBase @@ -13,7 +13,7 @@ public function testGetObjectWithHeader() $object = "upload-test-object-name.txt"; try { $res = $this->nosClient->getObject($this->bucket, $object, array( - NOSClient::NOS_LAST_MODIFIED => "xx" + NosClient::NOS_LAST_MODIFIED => "xx" )); $this->assertEquals(file_get_contents(__FILE__), $res); } catch (NosException $e) { @@ -26,7 +26,7 @@ public function testGetObjectWithIleggalEtag() $object = "upload-test-object-name.txt"; try { $res = $this->nosClient->getObject($this->bucket, $object, array( - NOSClient::NOS_ETAG => "xx" + NosClient::NOS_ETAG => "xx" )); $this->assertEquals(file_get_contents(__FILE__), $res); } catch (NosException $e) { @@ -62,8 +62,8 @@ public function testObject() $object = "upload-test-object-name.txt"; $content = file_get_contents(__FILE__); $options = array( - NOSClient::NOS_LENGTH => strlen($content), - NOSClient::NOS_HEADERS => array( + NosClient::NOS_LENGTH => strlen($content), + NosClient::NOS_HEADERS => array( 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', 'Cache-Control' => 'no-cache', 'Content-Disposition' => 'attachment;filename=oss_download.log', @@ -101,7 +101,7 @@ public function testObject() */ try { $options = array( - NOSClient::NOS_RANGE => '0-4' + NosClient::NOS_RANGE => '0-4' ); $content = $this->nosClient->getObject($this->bucket, $object, $options); $this->assertEquals($content, ' $localfile + NosClient::NOS_FILE_DOWNLOAD => $localfile ); try { diff --git a/tests/NOS/Tests/NosClientSignatureTest.php b/tests/NOS/Tests/NosClientSignatureTest.php index 5af6fbf..95e04bc 100644 --- a/tests/NOS/Tests/NosClientSignatureTest.php +++ b/tests/NOS/Tests/NosClientSignatureTest.php @@ -4,7 +4,7 @@ use NOS\Core\NosException; use NOS\Http\RequestCore; use NOS\Http\ResponseCore; -use NOS\NOSClient; +use NOS\NosClient; require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestNosClientBase.php'; diff --git a/tests/NOS/Tests/NosClientTest.php b/tests/NOS/Tests/NosClientTest.php index 7b86935..88d1517 100644 --- a/tests/NOS/Tests/NosClientTest.php +++ b/tests/NOS/Tests/NosClientTest.php @@ -1,7 +1,7 @@ assertFalse($nosClient->isUseSSL()); $nosClient->setUseSSL(true); $this->assertTrue($nosClient->isUseSSL()); @@ -27,7 +27,7 @@ public function testConstrunct() public function testConstrunct2() { try { - $nosClient = new NOSClient('id', "", 'http://nos-eastchina1.126.net'); + $nosClient = new NosClient('id', "", 'http://nos-eastchina1.126.net'); $this->assertNull($nosClient); $this->assertFalse(true); } catch (NosException $e) { @@ -38,7 +38,7 @@ public function testConstrunct2() public function testConstrunct3() { try { - $nosClient = new NOSClient("", 'key', 'http://nos-eastchina1.126.net'); + $nosClient = new NosClient("", 'key', 'http://nos-eastchina1.126.net'); $this->assertNull($nosClient); $this->assertFalse(true); } catch (NosException $e) { @@ -49,7 +49,7 @@ public function testConstrunct3() public function testConstrunct4() { try { - $nosClient = new NOSClient('id', 'key', ""); + $nosClient = new NosClient('id', 'key', ""); $this->assertNull($nosClient); $this->assertFalse(true); } catch (NosException $e) { @@ -60,7 +60,7 @@ public function testConstrunct4() public function testConstrunct5() { try { - $nosClient = new NOSClient('id', 'key', "123.123.123.1"); + $nosClient = new NosClient('id', 'key', "123.123.123.1"); $this->assertNotNull($nosClient); } catch (NosException $e) { $this->assertTrue(false); @@ -70,7 +70,7 @@ public function testConstrunct5() public function testConstrunct6() { try { - $nosClient = new NOSClient('id', 'key', "https://123.123.123.1"); + $nosClient = new NosClient('id', 'key', "https://123.123.123.1"); $this->assertTrue($nosClient->isUseSSL()); } catch (NosException $e) { $this->assertTrue(false); @@ -80,7 +80,7 @@ public function testConstrunct6() public function testConstrunct7() { try { - $nosClient = new NOSClient('id', 'key', "http://123.123.123.1"); + $nosClient = new NosClient('id', 'key', "http://123.123.123.1"); $this->assertFalse($nosClient->isUseSSL()); } catch (NosException $e) { $this->assertTrue(false); @@ -90,7 +90,7 @@ public function testConstrunct7() public function testConstrunct8() { try { - $nosClient = new NOSClient('id', 'key', "http://123.123.123.1", true); + $nosClient = new NosClient('id', 'key', "http://123.123.123.1", true); $nosClient->listBuckets(); $this->assertFalse(true); } catch (NosException $e) { @@ -107,7 +107,7 @@ public function testConstrunct9() var_dump($accessKeyId); var_dump($accessKeySecret); var_dump($endpoint); - $nosClient = new NOSClient($accessKeyId, $accessKeySecret , $endpoint, false); + $nosClient = new NosClient($accessKeyId, $accessKeySecret , $endpoint, false); $nosClient->listBuckets(); } catch (NosException $e) { echo $e->getMessage(); diff --git a/tests/NOS/Tests/TestNosClientBase.php b/tests/NOS/Tests/TestNosClientBase.php index d716366..3c4d264 100644 --- a/tests/NOS/Tests/TestNosClientBase.php +++ b/tests/NOS/Tests/TestNosClientBase.php @@ -1,7 +1,7 @@