public function getFileInfo($filename) { require_once LIBPATH . 'Qiniu/rs.php'; Qiniu_SetKeys($this->accessKey, $this->secretKey); $client = new Qiniu_MacHttpClient(null); $info = Qiniu_RS_Stat($client, $this->bucket, $filename); return array('info' => $info[0], 'error' => $info[1]); }
public function testStat() { 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); }
public function exists($filename) { $this->setBucketAndKey($filename); Qiniu_SetKeys($this->accessKey, $this->secretKey); $client = new \Qiniu_MacHttpClient(null); $result = Qiniu_RS_Stat($client, $this->bucket, $this->key); if ($result[0] !== NULL) { return true; } else { return false; } }
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); }
public function testPut() { $key = 'tmp/testPut' . getTid(); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); list($ret, $err) = Qiniu_RS_Put($this->client, $this->bucket, $key, 'hello world!', null); $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); }
public function testPut() { $key = 'testPut' . getTid(); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new Qiniu_RS_PutPolicy($this->bucket); $upToken = $putPolicy->Token(null); list($ret, $err) = Qiniu_Put($upToken, $key, "hello world!", null); $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); }
function qiniu() { echo 'qiniu'; $bucket = "xappqiniu"; $key = "apartment_1.jpg"; $accessKey = 'f9zK0PZeWtFNGY5lxrXeOM6MphG2xxNYBuXv6fGn'; $secretKey = 'PFSvanHSINAYXoW_-PBTUUNpkA7IU-w7q3pQ1JNj'; Qiniu_SetKeys($accessKey, $secretKey); $client = new Qiniu_MacHttpClient(null); list($ret, $err) = Qiniu_RS_Stat($client, $bucket, $key); echo "Qiniu_RS_Stat result: \n"; if ($err !== null) { var_dump($err); } else { var_dump($ret); } }
public function testLargePut() { $key = 'testRioLargePut' . getTid(); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new Qiniu_RS_PutPolicy($this->bucket); $upToken = $putPolicy->Token(null); $putExtra = new Qiniu_Rio_PutExtra($this->bucket); $reader = new MockReader(); list($ret, $err) = Qiniu_Rio_Put($upToken, $key, $reader, QINIU_RIO_BLOCK_SIZE + 5, $putExtra); $this->assertNull($err); $this->assertEquals($ret['hash'], "lgQEOCZ8Ievliq8XOfZmWTndgOll"); 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); }
public function testPutWithPersistentOps() { $key = 'testPutWithPersistentOps' . 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); list($ret, $err) = Qiniu_Put($upToken, $key, "hello world!", null); $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); }
*/ require_once 'bootstrap.php'; if (empty($_COOKIE["uid"]) || (int) $_COOKIE["uid"] < 1) { header("Location: login.php"); exit; } $uid = $_COOKIE["uid"]; $userinfo = $db->getOne("SELECT username FROM users WHERE id='{$uid}' LIMIT 1"); $username = $userinfo["username"]; if (isset($_GET["id"])) { $id = trim($_GET["id"]); $fileRow = $db->getOne("SELECT id, file_key, file_name, file_size, created_at FROM uploads WHERE id='{$id}' LIMIT 1"); $key = $fileRow["file_key"]; $attName = $fileRow["file_name"]; if (!empty($id)) { list($ret, $err) = Qiniu_RS_Stat($client, $bucket, $key); if ($err == null) { $base_url = Qiniu_RS_MakeBaseUrl($domain, $key); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>相册 - 浏览图片</title> </head> <body> <p>欢迎您,<?php
function getMeta($path, $force = 0) { global $_G, $_GET, $documentexts, $imageexts; $arr = self::parsePath($path); $client = self::init($path, 1); $icosdata = array(); list($meta, $err) = Qiniu_RS_Stat($client, $arr['bucket'], $arr['object']); if ($err !== null) { runlog('qiniu_log', $err->Code . ':' . $err->Err); return array('error' => $err->Code . ':' . $err->Err); } $meta['key'] = substr($arr['object'], strrchr($meta['key'], '/')); $icosdata = self::_formatMeta($meta, $arr); return $icosdata; }
public function testPut_exclusive() { $key = 'testPut_exclusive' . getTid(); $scope = $this->bucket . ':' . $key; $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new Qiniu_RS_PutPolicy($scope); $putPolicy->InsertOnly = 1; $upToken = $putPolicy->Token(null); list($ret, $err) = Qiniu_Put($upToken, $key, "hello world!", null); $this->assertNull($err); list($ret, $err) = Qiniu_PutFile($upToken, $key, __FILE__, null); $this->assertNull($ret); $this->assertEquals($err->Code, 614); var_dump($err); list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); $this->assertEquals($ret['mimeType'], 'application/octet-stream'); var_dump($ret); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }
$serverUrl = $row3['p_server']; $fileDir = $row3['p_dir']; $bucketName = $row3['p_bucketname']; $ak = $row3['p_ak']; $sk = $row3['p_sk']; $operator_name = $row3['p_op_name']; $operator_pwd = $row3['p_op_pwd']; } if (empty($uploadUser)) { $uploadUser = "******"; } switch ($policyType) { case 'qiniu': Qiniu_SetKeys($ak, $sk); $client = new Qiniu_MacHttpClient(null); list($ret, $err) = Qiniu_RS_Stat($client, $bucketName, $ming); if ($err !== null) { var_dump($err); } else { echo $ret['fsize'] . "." . $uploadUser . "(UID)" . "." . $ret['mimeType'] . "." . $uploadTime; } break; case 'local': $fileAction = fopen(dirname(dirname(__FILE__)) . "/" . $fileDir . "/" . $ming, "r"); $fileInfo = fstat($fileAction); echo $fileInfo['size'] . "." . $uploadUser . "(UID)" . "." . "暂不提供" . "." . $uploadTime; fclose($fileAction); break; case 'server': $infoToken = md5($ming . 'info' . $ak); $postResult = curl_post($serverUrl, array('action' => 'info', 'filedir' => $fileDir, 'filename' => $ming, 'token' => $infoToken));
/** * get file state in qiniu * @return [$ret, $err] */ public function getFileInfo($fileName) { Qiniu_setKeys(QINIU_ACCESS_KEY, QINIU_SECRET_KEY); $client = new \Qiniu_MacHttpClient(null); return Qiniu_RS_Stat($client, $this->bucket, $fileName); }
/** * Get the metadata of a file * * @param $path * @return array */ public function getMetadata($path) { list($ret, $err) = Qiniu_RS_Stat($this->getClient(), $this->bucket, $path); if ($err !== null) { return false; } $ret['key'] = $path; return $this->normalizeData($ret); }
/** * 查看指定文件是否存在于七牛,及其信息 * @param string $key 文件名 * @return array 信息 */ public static function getFileInfoFromQiniu($key) { Qiniu_SetKeys(W2Config::$Qiniu_accessKey, W2Config::$Qiniu_secretKey); $client = new Qiniu_MacHttpClient(null); list($ret, $err) = Qiniu_RS_Stat($client, W2Config::$Qiniu_bucket, $key); if ($err !== null) { return $err; } else { $ret['urlPreview'] = W2Qiniu::getBaseUrl($key); $ret['urlDownload'] = W2Qiniu::getPrivateUrl($ret['urlPreview']); return $ret; } }
public function viewFileInfoByKey($key) { list($ret, $err) = Qiniu_RS_Stat(new Qiniu_MacHttpClient(null), $this->_Bucket, $key); var_dump($ret, $err); }
public function stat($key) { list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key); if ($err !== null) { throw new QiniuStatException($err->Err, $err->Code, $key); } else { return $ret; } }