예제 #1
0
 public function testStat()
 {
     $putPolicy = new QiniuRSPutPolicy($this->bucket . ":" . $this->key);
     $upToken = $putPolicy->Token(null);
     list($ret, $err) = QiniuPutExtra::Qiniu_PutFile($upToken, $this->key, __FILE__, null);
     $this->assertNull($err);
     RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $this->notExistKey);
     list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $this->key);
     $this->assertArrayHasKey('hash', $ret);
     $this->assertNull($err);
     list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $this->notExistKey);
     $this->assertNull($ret);
     $this->assertFalse($err === null);
 }
예제 #2
0
 public function testPut()
 {
     $key = 'tmp/testPut' . getTid();
     $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key);
     list($ret, $err) = RSUtils::Qiniu_RS_Put($this->client, $this->bucket, $key, 'hello world!', null);
     $this->assertNull($err);
     $this->assertArrayHasKey('hash', $ret);
     var_dump($ret);
     list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $key);
     $this->assertNull($err);
     var_dump($ret);
     $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $this->assertNull($err);
 }
예제 #3
0
 public function testPutWithPersistentOps()
 {
     $key = 'testPutWithPersistentOps' . getTid();
     $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $putPolicy = new QiniuRSPutPolicy($this->bucket);
     $putPolicy->PersistentOps = 'avthumb/mp3';
     $putPolicy->PersistentNotifyUrl = 'http://someurl/abc';
     $upToken = $putPolicy->Token(null);
     list($ret, $err) = QiniuPutExtra::Qiniu_Put($upToken, $key, "hello world!", null);
     $this->assertNull($err);
     $this->assertArrayHasKey('hash', $ret);
     $this->assertArrayHasKey('persistentId', $ret);
     var_dump($ret);
     list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $key);
     $this->assertNull($err);
     var_dump($ret);
     $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $this->assertNull($err);
 }
예제 #4
0
 public function testLargePut()
 {
     if (getTestEnv() == "travis") {
         return;
     }
     $key = 'testRioLargePut' . getTid();
     $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $putPolicy = new QiniuRSPutPolicy($this->bucket);
     $upToken = $putPolicy->Token(null);
     $putExtra = new QiniuRioPutExtra($this->bucket);
     $putExtra->Params = array('x:test' => 'test');
     $reader = new \MockReader();
     list($ret, $err) = QiniuRioUploadClient::Qiniu_Rio_Put($upToken, $key, $reader, QiniuRioPutExtra::QINIU_RIO_BLOCK_SIZE() + 5, $putExtra);
     $this->assertNull($err);
     $this->assertEquals($ret['hash'], "lgQEOCZ8Ievliq8XOfZmWTndgOll");
     $this->assertEquals($ret['x:test'], "test");
     var_dump($ret);
     list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $key);
     $this->assertNull($err);
     var_dump($ret);
     $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $this->assertNull($err);
 }
예제 #5
0
 public function testPut_exclusive()
 {
     $key = 'testPut_exclusive' . getTid();
     $scope = $this->bucket . ':' . $key;
     $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $putPolicy = new QiniuRSPutPolicy($scope);
     $putPolicy->InsertOnly = 1;
     $upToken = $putPolicy->Token(null);
     list($ret, $err) = QiniuPutExtra::Qiniu_Put($upToken, $key, "hello world!", null);
     $this->assertNull($err);
     list($ret, $err) = QiniuPutExtra::Qiniu_PutFile($upToken, $key, __FILE__, null);
     $this->assertNull($ret);
     $this->assertEquals($err->Code, 614);
     var_dump($err);
     list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $key);
     $this->assertNull($err);
     $this->assertEquals($ret['mimeType'], 'application/octet-stream');
     var_dump($ret);
     $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $this->assertNull($err);
 }