本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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]);
}
示例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;
}
}
示例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);
}
示例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'];
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
}
示例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);
}
}