コード例 #1
0
ファイル: resumable_io.php プロジェクト: ijustyce/zblogphp
function Qiniu_Rio_Put($upToken, $key, $body, $fsize, $putExtra)
{
    global $QINIU_UP_HOST;
    $self = new Qiniu_Rio_UploadClient($upToken);
    $progresses = array();
    $uploaded = 0;
    while ($uploaded < $fsize) {
        if ($fsize < $uploaded + QINIU_RIO_BLOCK_SIZE) {
            $bsize = $fsize - $uploaded;
        } else {
            $bsize = QINIU_RIO_BLOCK_SIZE;
        }
        list($blkputRet, $err) = Qiniu_Rio_Mkblock($self, $QINIU_UP_HOST, $body, $bsize);
        $host = $blkputRet['host'];
        $uploaded += $bsize;
        $progresses[] = $blkputRet;
    }
    $putExtra->Progresses = $progresses;
    return Qiniu_Rio_Mkfile($self, $QINIU_UP_HOST, $key, $fsize, $putExtra);
}
コード例 #2
0
ファイル: resumable_io.php プロジェクト: druphliu/dzzoffice
function Qiniu_Rio_Put($upToken, $key, $body, $fsize, $putExtra)
{
    global $QINIU_UP_HOST;
    $self = new Qiniu_Rio_UploadClient($upToken);
    $progresses = array();
    $uploaded = 0;
    while ($uploaded < $fsize) {
        $tried = 0;
        $tryTimes = $putExtra->TryTimes > 0 ? $putExtra->TryTimes : 1;
        $blkputRet = null;
        $err = null;
        if ($fsize < $uploaded + QINIU_RIO_BLOCK_SIZE) {
            $bsize = $fsize - $uploaded;
        } else {
            $bsize = QINIU_RIO_BLOCK_SIZE;
        }
        while ($tried < $tryTimes) {
            list($blkputRet, $err) = 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 Qiniu_Error(0, "rio: uploaded without ret");
            return array(null, $err);
        }
        $uploaded += $bsize;
        $progresses[] = $blkputRet;
    }
    $putExtra->Progresses = $progresses;
    return Qiniu_Rio_Mkfile($self, $QINIU_UP_HOST, $key, $fsize, $putExtra);
}