當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Qiniu_PutFile函數代碼示例

本文整理匯總了PHP中Qiniu_PutFile函數的典型用法代碼示例。如果您正苦於以下問題:PHP Qiniu_PutFile函數的具體用法?PHP Qiniu_PutFile怎麽用?PHP Qiniu_PutFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Qiniu_PutFile函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: upload_to_qiniu

/**
 * Created by PhpStorm.
 * User: xingminglister
 * Date: 4/18/14
 * Time: 3:50 PM
 */
function upload_to_qiniu($filepath)
{
    require_once "qiniu/io.php";
    require_once "qiniu/rs.php";
    $bucket = "hitour";
    $qiniu_link = '';
    $names = pathinfo($filepath);
    $qiniu_key = md5($filepath) . (empty($names['extension']) ? '' : '.' . $names['extension']);
    $putPolicy = new Qiniu_RS_PutPolicy($bucket);
    $upToken = $putPolicy->Token(null);
    $putExtra = new Qiniu_PutExtra();
    $putExtra->Crc32 = 1;
    list($ret, $err) = Qiniu_PutFile($upToken, $qiniu_key, $filepath, $putExtra);
    //	echo "[" . (date('Ymd H:i:s', time())) . "] ====> Qiniu_PutFile result: \n";
    if ($err !== null) {
        if ($err->Code == 614) {
            $qiniu_link = 'http://hitour.qiniudn.com/' . $qiniu_key;
        }
        //		echo $filepath . "\n";
        //		var_dump($err);
    } else {
        //		var_dump($ret);
        if (!empty($ret['key'])) {
            $qiniu_link = 'http://hitour.qiniudn.com/' . $ret['key'];
        }
    }
    return $qiniu_link;
}
開發者ID:Veaer,項目名稱:StoryAppendDemo-Server,代碼行數:34,代碼來源:ToQiniu.php

示例2: upload_qiniu

 public function upload_qiniu($file = "", $name = "")
 {
     $path = $_SERVER['DOCUMENT_ROOT'];
     require_once $path . "/app/libraries/qiniu/rs.php";
     require_once $path . "/app/libraries/qiniu/io.php";
     $bucket = "meilimei";
     $local_file = "upload/" . $name;
     $key = $local_file;
     $accessKey = 'tjtiZoMyJa9ggnNisrdocCCGvTlNLFvYxGMMQ6LF';
     $secretKey = '6zQXHont_jN-QFznn96H4oKA7IUqjibPeC-Yto62';
     Qiniu_SetKeys($accessKey, $secretKey);
     $putPolicy = new Qiniu_RS_PutPolicy($bucket);
     $upToken = $putPolicy->Token(null);
     if (move_uploaded_file($file, $local_file)) {
         $upload_file = $path . "/upload/" . $name;
         $putExtra = new Qiniu_PutExtra();
         $putExtra->Crc32 = 1;
         list($ret, $err) = Qiniu_PutFile($upToken, $key, $upload_file, $putExtra);
         if ($err !== null) {
             return false;
         } else {
             //var_dump($ret);
             return $ret;
         }
     } else {
         return false;
         // 			echo "move_uploaded錯誤!";
         // 			die;
     }
     return false;
 }
開發者ID:sexseses,項目名稱:meilimei_old_api,代碼行數:31,代碼來源:remote.php

示例3: saveFile

 public function saveFile($token, $filename, $file, $ext = null)
 {
     list($ret, $err) = Qiniu_PutFile($token, $filename, $file, $ext);
     if (!empty($err)) {
         throw new Exception(print_r($err, 1));
     }
     return $ret;
 }
開發者ID:daysun1987,項目名稱:daydaynews,代碼行數:8,代碼來源:Qiniu.php

示例4: upload

 public function upload($key, $source)
 {
     Qiniu_SetKeys($this->accessKey, $this->secretKey);
     $putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
     $upToken = $putPolicy->Token(null);
     $putExtra = new Qiniu_PutExtra();
     $putExtra->Crc32 = 1;
     return Qiniu_PutFile($upToken, $key, $source, $putExtra);
 }
開發者ID:udeth,項目名稱:YOF,代碼行數:9,代碼來源:L_Qiniu.class.php

示例5: uploadfile

 public function uploadfile($file_path)
 {
     list($ret, $err) = Qiniu_PutFile($this->upToken, $file_path, @$_FILES['file']['tmp_name'], $this->putExtra);
     @($ret['key'] = $this->file_domain . @$ret['key']);
     //
     if ($err !== null) {
         return $err;
     } else {
         return $ret;
     }
 }
開發者ID:stoneStyle,項目名稱:startbbs,代碼行數:11,代碼來源:Qiniu_lib.php

示例6: upFile

 public function upFile($filename, $filepath)
 {
     require_once LIBPATH . 'Qiniu/io.php';
     require_once LIBPATH . 'Qiniu/rs.php';
     $this->getUpToken();
     Qiniu_SetKeys($accessKey, $secretKey);
     $putExtra = new Qiniu_PutExtra();
     $putExtra->Crc32 = 1;
     $info = Qiniu_PutFile($this->upToken, $filename, $filepath, $putExtra);
     return array('info' => $info[0], 'error' => $info[1]);
 }
開發者ID:zuozuoba,項目名稱:zpf,代碼行數:11,代碼來源:QiNiu.php

示例7: upload

 public function upload($filename, $filepath)
 {
     $putExtra = new Qiniu_PutExtra();
     $putExtra->Crc32 = 1;
     $filename = $this->newfilename($filename);
     list($ret, $err) = Qiniu_PutFile($this->uptoken(), $filename, $filepath, $putExtra);
     if ($err !== null) {
         return false;
     } else {
         return $ret;
     }
 }
開發者ID:huangbinzd,項目名稱:kppwGit,代碼行數:12,代碼來源:QiniuClass.php

示例8: testStat

 public function testStat()
 {
     $putPolicy = new Qiniu_RS_PutPolicy($this->bucket . ":" . $this->key);
     $upToken = $putPolicy->Token(null);
     list($ret, $err) = Qiniu_PutFile($upToken, $this->key, __FILE__, null);
     $this->assertNull($err);
     Qiniu_RS_Delete($this->client, $this->bucket, $this->notExistKey);
     list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $this->key);
     $this->assertArrayHasKey('hash', $ret);
     $this->assertNull($err);
     list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $this->notExistKey);
     $this->assertNull($ret);
     $this->assertFalse($err === null);
 }
開發者ID:timelessmemory,項目名稱:uhkklp,代碼行數:14,代碼來源:RsTest.php

示例9: write

 public function write($filename, $filePath)
 {
     $this->setBucketAndKey($filename);
     Qiniu_SetKeys($this->accessKey, $this->secretKey);
     $putPolicy = new \Qiniu_RS_PutPolicy($this->bucket);
     $upToken = $putPolicy->Token(null);
     $putExtra = new \Qiniu_PutExtra();
     $putExtra->Crc32 = 1;
     list($ret, $err) = Qiniu_PutFile($upToken, $this->key, $filePath, $putExtra);
     if ($err !== null) {
         throw new RuntimeException('Qiniu::write Error. ' . 'TargetFilename: ' . $filename . ', LocalFile: ' . $filePath . ', Reqid: ' . $err->Reqid . ', Err: ' . $err->Err, $err->Code);
     } else {
         return $ret['hash'];
     }
 }
開發者ID:musicsnap,項目名稱:Yaf.Global.Library,代碼行數:15,代碼來源:Qiniu.php

示例10: uploadFile

 /**
  * 上傳文件
  * @param type $uploadFile 文本框上傳文件名
  * @param type $qiniuFileName 存儲在七牛裏麵的文件名
  */
 public function uploadFile($uploadFile, $qiniuFileName)
 {
     require_once 'qiniu/io.php';
     $file = $_FILES[$uploadFile]['tmp_name'];
     // 上傳文件的位置
     $putPolicy = new Qiniu_RS_PutPolicy($this->_bucket);
     $upToken = $putPolicy->Token(null);
     $putExtra = new Qiniu_PutExtra();
     $putExtra->Crc32 = 1;
     list($ret, $err) = Qiniu_PutFile($upToken, $qiniuFileName, $file, $putExtra);
     if ($err !== null) {
         return array('succ' => false, 'data' => $err);
     } else {
         //            picThumb($accessKey, $secretKey, $key1, $width=100, $height=100);
         return array('succ' => true, 'data' => $ret);
     }
 }
開發者ID:sunlyliuh,項目名稱:myproject,代碼行數:22,代碼來源:qiniu.class.php

示例11: testPutFile

 public function testPutFile()
 {
     $key = 'testPutFile' . getTid();
     $err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
     $upToken = $putPolicy->Token(null);
     $putExtra = new Qiniu_PutExtra();
     $putExtra->CheckCrc = 1;
     list($ret, $err) = Qiniu_PutFile($upToken, $key, __FILE__, $putExtra);
     $this->assertNull($err);
     $this->assertArrayHasKey('hash', $ret);
     var_dump($ret);
     list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key);
     $this->assertNull($err);
     var_dump($ret);
     $err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $this->assertNull($err);
 }
開發者ID:rwifeng,項目名稱:7niu,代碼行數:18,代碼來源:IoTest.php

示例12: testPutFileWithPersistentOps

 public function testPutFileWithPersistentOps()
 {
     $key = 'testPutFileWithPersistentOps' . getTid();
     $err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $putPolicy = new Qiniu_RS_PutPolicy($this->bucket);
     $putPolicy->PersistentOps = 'avthumb/mp3';
     $putPolicy->PersistentNotifyUrl = 'http://someurl/abc';
     $upToken = $putPolicy->Token(null);
     $putExtra = new Qiniu_PutExtra();
     $putExtra->CheckCrc = 1;
     list($ret, $err) = Qiniu_PutFile($upToken, $key, __FILE__, $putExtra);
     $this->assertNull($err);
     $this->assertArrayHasKey('hash', $ret);
     $this->assertArrayHasKey('persistentId', $ret);
     var_dump($ret);
     list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key);
     $this->assertNull($err);
     var_dump($ret);
     $err = Qiniu_RS_Delete($this->client, $this->bucket, $key);
     $this->assertNull($err);
 }
開發者ID:timelessmemory,項目名稱:uhkklp,代碼行數:21,代碼來源:PersistentTest.php

示例13: uploadFile

 /**
  * 文件上傳
  * @param string $filePath 待上傳文件的絕對路徑
  * @return string 上傳成功後的URL,失敗時返回空
  */
 public function uploadFile($filePath)
 {
     $fileUrl = '';
     if (!file_exists($filePath)) {
         return $fileUrl;
     }
     $config = $this->config;
     $fileName = date('YmdHis_', $_SERVER['REQUEST_TIME']) . md5(PhalApi_Tool::createRandStr(8) . microtime(true));
     Qiniu_SetKeys($config['accessKey'], $config['secretKey']);
     $putPolicy = new Qiniu_RS_PutPolicy($config['space_bucket']);
     $upToken = $putPolicy->Token(null);
     $putExtra = new Qiniu_PutExtra();
     $putExtra->Crc32 = 1;
     list($ret, $err) = Qiniu_PutFile($upToken, $fileName, $filePath, $putExtra);
     if ($err !== null) {
         DI()->logger->debug('failed to upload file to qiniu', array('Err' => $err->Err, 'Reqid' => $err->Reqid, 'Details' => $err->Details, 'Code' => $err->Code));
     } else {
         $fileUrl = $config['space_host'] . '/' . $fileName;
         DI()->logger->debug('succeed to upload file to qiniu', $ret);
     }
     return $fileUrl;
 }
開發者ID:WJayWJay,項目名稱:phalapi-library,代碼行數:27,代碼來源:Lite.php

示例14: upload

 /**
  * Upload file to qiniu cloud
  * @param  string $filePath file path
  * @param  string $key      file name in qiniu
  * @param  bool   $isAllowedOverwrite
  */
 public function upload($filePath, $key, $isAllowedOverwrite = false)
 {
     if ($isAllowedOverwrite) {
         $upToken = $this->getToken($key);
     } else {
         $upToken = $this->getToken();
     }
     if (filesize($filePath) > 1 << self::QINIU_UPLOAD_BLOCK_BITS) {
         LogUtil::info(['message' => 'upload file use block', 'filePath' => $filePath], 'resque');
         $putExtra = new \Qiniu_Rio_PutExtra();
         list($ret, $err) = Qiniu_Rio_PutFile($upToken, $key, $filePath, $putExtra);
     } else {
         LogUtil::info(['message' => 'upload file directly', 'filePath' => $filePath], 'resque');
         $putExtra = new \Qiniu_PutExtra();
         $putExtra->Crc32 = 1;
         list($ret, $err) = Qiniu_PutFile($upToken, $key, $filePath, $putExtra);
     }
     if ($err !== null) {
         return $err;
     } else {
         return $ret;
     }
 }
開發者ID:timelessmemory,項目名稱:uhkklp,代碼行數:29,代碼來源:Qiniu.php

示例15: sendToQiniu

 /**
  * $filename 七牛可以手動填寫路徑
  */
 function sendToQiniu($path, $filename)
 {
     Qiniu_setKeys(self::$qiniuAccessKey, self::$qiniuSecretKey);
     $qiniu = new Qiniu_MacHttpClient(null);
     $putPolicy = new Qiniu_RS_PutPolicy(self::$bucket);
     $upToken = $putPolicy->Token(null);
     $putExtra = new Qiniu_PutExtra();
     $putExtra->Crc32 = 1;
     list($ret, $err) = Qiniu_PutFile($upToken, $filename, $path, $putExtra);
     if ($err) {
         return array('code' => -2, 'msg' => $err);
     } else {
         $file = $ret['key'];
         $domain = self::$bucket . '.qiniudn.com';
         $baseUrl = Qiniu_RS_MakeBaseUrl($domain, $file);
         $private = false;
         if ($private) {
             $getPolicy = new Qiniu_RS_GetPolicy();
             $baseUrl = $getPolicy->MakeRequest($baseUrl, null);
         }
         return array('code' => 0, 'msg' => $baseUrl);
     }
 }
開發者ID:highestgoodlikewater,項目名稱:spider-3,代碼行數:26,代碼來源:uploader.class.php


注:本文中的Qiniu_PutFile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。