예제 #1
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);
 }
 static function Qiniu_Rio_Put($upToken, $key, $body, $fsize, $putExtra)
 {
     $QINIU_UP_HOST = Conf::$QINIU_UP_HOST;
     $self = new QiniuRioUploadClient($upToken);
     $progresses = array();
     $uploaded = 0;
     while ($uploaded < $fsize) {
         $tried = 0;
         $tryTimes = $putExtra->TryTimes > 0 ? $putExtra->TryTimes : 1;
         $blkputRet = null;
         $err = null;
         if ($fsize < $uploaded + QiniuRioPutExtra::QINIU_RIO_BLOCK_SIZE()) {
             $bsize = $fsize - $uploaded;
         } else {
             $bsize = QiniuRioPutExtra::QINIU_RIO_BLOCK_SIZE();
         }
         while ($tried < $tryTimes) {
             list($blkputRet, $err) = QiniuRioPutExtra::Qiniu_Rio_Mkblock($self, $QINIU_UP_HOST, $body, $bsize);
             if ($err === null) {
                 break;
             }
             $tried += 1;
             continue;
         }
         if ($err !== null) {
             return array(null, $err);
         }
         if ($blkputRet === null) {
             $err = new QiniuError(0, "rio: uploaded without ret");
             return array(null, $err);
         }
         $uploaded += $bsize;
         $progresses[] = $blkputRet;
     }
     $putExtra->Progresses = $progresses;
     return QiniuRioPutExtra::Qiniu_Rio_Mkfile($self, $QINIU_UP_HOST, $key, $fsize, $putExtra);
 }
예제 #3
0
 static function Qiniu_Rio_BlockCount($fsize)
 {
     return $fsize + (QiniuRioPutExtra::QINIU_RIO_BLOCK_SIZE() - 1) >> QiniuRioPutExtra::QINIU_RIO_BLOCK_BITS;
 }