예제 #1
0
파일: io.php 프로젝트: stoneStyle/startbbs
function Qiniu_PutFile($upToken, $key, $localFile, $putExtra)
{
    global $QINIU_UP_HOST;
    if ($putExtra === null) {
        $putExtra = new Qiniu_PutExtra();
    }
    $fields = array('token' => $upToken, 'file' => createFile($localFile, $putExtra->MimeType));
    if ($key !== null) {
        $fields['key'] = $key;
    }
    if ($putExtra->CheckCrc) {
        if ($putExtra->CheckCrc === 1) {
            $hash = hash_file('crc32b', $localFile);
            $array = unpack('N', pack('H*', $hash));
            $putExtra->Crc32 = $array[1];
        }
        $fields['crc32'] = sprintf('%u', $putExtra->Crc32);
    }
    if ($putExtra->Params) {
        foreach ($putExtra->Params as $k => $v) {
            $fields[$k] = $v;
        }
    }
    $client = new Qiniu_HttpClient();
    return Qiniu_Client_CallWithForm($client, $QINIU_UP_HOST, $fields, 'multipart/form-data');
}
예제 #2
0
파일: io.php 프로젝트: duxiangfei/plugins
function Qiniu_PutFile($upToken, $key, $localFile, $putExtra)
{
    global $QINIU_UP_HOST;
    if ($putExtra === null) {
        $putExtra = new Qiniu_PutExtra();
    }
    if (!empty($putExtra->MimeType)) {
        $localFile .= ';type=' . $putExtra->MimeType;
    }
    $fields = array('token' => $upToken, 'file' => '@' . $localFile);
    if ($key === null) {
        $fname = '?';
    } else {
        $fname = $key;
        $fields['key'] = $key;
    }
    if ($putExtra->CheckCrc) {
        if ($putExtra->CheckCrc === 1) {
            $hash = hash_file('crc32b', $localFile);
            $array = unpack('N', pack('H*', $hash));
            $putExtra->Crc32 = $array[1];
        }
        $fields['crc32'] = sprintf('%u', $putExtra->Crc32);
    }
    $client = new Qiniu_HttpClient();
    return Qiniu_Client_CallWithForm($client, $QINIU_UP_HOST, $fields, 'multipart/form-data');
}
예제 #3
0
파일: pfop.php 프로젝트: huangbinzd/kppwGit
 public function MakeRequest($self)
 {
     global $QINIU_API_HOST;
     $ReqParams = array('bucket' => $this->Bucket, 'key' => $this->Key, 'fops' => $this->Fops, 'notifyURL' => $this->NotifyURL, 'force' => $this->Force, 'pipeline' => $this->Pipeline);
     $url = $QINIU_API_HOST . '/pfop/';
     return Qiniu_Client_CallWithForm($self, $url, $ReqParams);
 }
예제 #4
0
function Qiniu_Rio_Mkfile($self, $host, $key, $fsize, $extra)
{
    $entry = $extra->Bucket . ':' . $key;
    $url = $host . '/rs-mkfile/' . Qiniu_Encode($entry) . '/fsize/' . $fsize;
    if (!empty($extra->MimeType)) {
        $url .= '/mimeType/' . Qiniu_Encode($extra->MimeType);
    }
    $ctxs = array();
    foreach ($extra->Progresses as $prog) {
        $ctxs[] = $prog['ctx'];
    }
    $body = implode(',', $ctxs);
    return Qiniu_Client_CallWithForm($self, $url, $body, 'text/plain');
}
예제 #5
0
function Qiniu_Rio_Mkfile($self, $host, $key, $fsize, $extra)
{
    $url = $host . '/mkfile/' . $fsize;
    if ($key !== null) {
        $url .= '/key/' . Qiniu_Encode($key);
    }
    if (!empty($extra->MimeType)) {
        $url .= '/mimeType/' . Qiniu_Encode($extra->MimeType);
    }
    $ctxs = array();
    foreach ($extra->Progresses as $prog) {
        $ctxs[] = $prog['ctx'];
    }
    $body = implode(',', $ctxs);
    return Qiniu_Client_CallWithForm($self, $url, $body, 'application/octet-stream');
}
function Qiniu_RS_Batch($self, $ops)
{
    global $QINIU_RS_HOST;
    $url = $QINIU_RS_HOST . '/batch';
    $params = 'op=' . implode('&op=', $ops);
    return Qiniu_Client_CallWithForm($self, $url, $params);
}
예제 #7
0
require_once "../../qiniu/http.php";
require_once "../../qiniu/auth_digest.php";
require_once "../../qiniu/utils.php";
$accessKey = "";
$secretKey = "";
$bucket = "";
$key = "";
$fops = "";
$notifyURL = "";
$force = 0;
$encodedBucket = urlencode($bucket);
$encodedKey = urlencode($key);
$encodedFops = urlencode($fops);
$encodedNotifyURL = urlencode($notifyURL);
$apiHost = "http://api.qiniu.com";
$apiPath = "/pfop/";
$requestBody = "bucket={$encodedBucket}&key={$encodedKey}&fops={$encodedFops}&notifyURL={$encodedNotifyURL}";
if ($force !== 0) {
    $requestBody .= "&force=1";
}
$mac = new Qiniu_Mac($accessKey, $secretKey);
$client = new Qiniu_MacHttpClient($mac);
list($ret, $err) = Qiniu_Client_CallWithForm($client, $apiHost . $apiPath, $requestBody);
if ($err !== null) {
    echo "failed\n";
    var_dump($err);
} else {
    echo "success\n";
    var_dump($ret);
}
예제 #8
0
파일: http.php 프로젝트: huangbinzd/kppwGit
function Qiniu_Client_CallWithMultipartForm($self, $url, $fields, $files)
{
    list($contentType, $body) = Qiniu_Build_MultipartForm($fields, $files);
    return Qiniu_Client_CallWithForm($self, $url, $body, $contentType);
}
예제 #9
0
파일: W2Qiniu.php 프로젝트: alonexy/lea
 public static function getZipInfo($fileList = array(), $saveas = '')
 {
     require_once __DIR__ . '/../qiniu/http.php';
     require_once __DIR__ . '/../qiniu/auth_digest.php';
     require_once __DIR__ . '/../qiniu/utils.php';
     $fops = 'mkzip/2';
     $extraKey = null;
     // var_export($fileList);
     foreach ($fileList as $key => $value) {
         if (preg_match('/^http:\\/\\//', $value)) {
             if (is_int($key)) {
                 $fops .= '/url/' . Qiniu_Encode($value);
             } else {
                 $fops .= '/url/' . Qiniu_Encode($value);
                 // $fops .= '/alias/'.Qiniu_Encode($key);
                 // var_export($key);
                 // var_export(Qiniu_Encode($key));
                 $fops .= '/alias/' . Qiniu_Encode($key);
             }
             if ($extraKey == null) {
                 $extraKey = $value;
             }
         }
     }
     if ($saveas == null) {
         $saveas = md5($fops) . '.zip';
     }
     if ($saveas != null) {
         $fops .= '|saveas/' . Qiniu_Encode(W2Config::$Qiniu_bucket . ':' . $saveas);
     }
     $persistentKey = 'mkzip.' . $saveas . '.pfop';
     $saveFileInfo = W2Qiniu::getFileInfoFromQiniu($saveas);
     if (is_array($saveFileInfo) && array_key_exists('fsize', $saveFileInfo)) {
         return $saveFileInfo;
     }
     $persistentId = W2Qiniu::getKeyContent($persistentKey);
     if (!is_null($persistentId)) {
         return W2Qiniu::getPersistentInfo($persistentId);
     }
     if (strpos($extraKey, W2Config::$Qiniu_domain) != false) {
         $extraKey = str_replace('http://' . W2Config::$Qiniu_domain . '/', '', $extraKey);
     }
     $notifyURL = "";
     $force = 0;
     $encodedBucket = urlencode(W2Config::$Qiniu_bucket);
     $encodedKey = urlencode($extraKey);
     $encodedFops = urlencode($fops);
     $encodedNotifyURL = urlencode($notifyURL);
     $apiHost = "http://api.qiniu.com";
     $apiPath = "/pfop/";
     $requestBody = "bucket={$encodedBucket}&key={$encodedKey}&fops={$encodedFops}&notifyURL={$encodedNotifyURL}";
     if ($force !== 0) {
         $requestBody .= "&force=1";
     }
     $mac = new Qiniu_Mac(W2Config::$Qiniu_accessKey, W2Config::$Qiniu_secretKey);
     $client = new Qiniu_MacHttpClient($mac);
     list($ret, $err) = Qiniu_Client_CallWithForm($client, $apiHost . $apiPath, $requestBody);
     if ($err !== null) {
         var_dump($err);
     } else {
         if (is_array($ret) && array_key_exists('persistentId', $ret)) {
             W2Qiniu::setKeyContent($persistentKey, $ret['persistentId']);
             return W2Qiniu::getPersistentInfo($ret['persistentId']);
         }
         return $ret;
     }
 }