Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqiujiansong committed Aug 11, 2016
1 parent ac39976 commit 3c4ee23
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 56 deletions.
10 changes: 5 additions & 5 deletions samples/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once __DIR__ . '/Common.php';

use NOS\NOSClient;
use NOS\NosClient;
use NOS\Core\NosException;

$bucket = Common::getTestBucketName();
Expand All @@ -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");
}

Expand All @@ -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);
Expand All @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions samples/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
require_once __DIR__ . '/Config.php';

use NOS\NOSClient;
use NOS\NosClient;
use NOS\Core\NosException;

class Common
Expand All @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down
18 changes: 9 additions & 9 deletions samples/MultipartUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once __DIR__ . '/Common.php';

use NOS\NOSClient;
use NOS\NosClient;
use NOS\Core\NosUtil;
use NOS\Core\NosException;

Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions samples/Object.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
require_once __DIR__ . '/Common.php';

use NOS\NOSClient;
use NOS\NosClient;
use NOS\Core\NosException;

$bucket = Common::getTestBucketName();
Expand All @@ -21,7 +21,7 @@
Common::println("b.file is fetched, the content is: " . $content);

$options = array(
NOSClient::NOS_FILE_DOWNLOAD => "./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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion samples/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/NOS/NOSClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* 用户通过NOSClient实例可以进行Object,MultipartUpload等操作,具体
* 的接口规则可以参考官方NOS API文档
*/
class NOSClient
class NosClient
{

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/NOS/Tests/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

require_once __DIR__ . '/../../../autoload.php';

use NOS\NOSClient;
use NOS\NosClient;
use NOS\Core\NosException;

class Common
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions tests/NOS/Tests/NosClientBucketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions tests/NOS/Tests/NosClientMultipartUploadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions tests/NOS/Tests/NosClientObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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, '<?php');
Expand Down Expand Up @@ -139,7 +139,7 @@ public function testObject()
*/
$localfile = "upload-test-object-name-local.txt";
$options = array(
NOSClient::NOS_FILE_DOWNLOAD => $localfile
NosClient::NOS_FILE_DOWNLOAD => $localfile
);

try {
Expand Down
2 changes: 1 addition & 1 deletion tests/NOS/Tests/NosClientSignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Loading

0 comments on commit 3c4ee23

Please sign in to comment.