Example #1
0
 /**
  * 上传文件流
  * @param  integer $userid       用户自定义分类
  * @param  string  $file_data    文件内容
  * @param  string  $session      上传唯一标识符
  * @param  string  $offset 		 开始传输的位移
  * @return [type]                [description]
  */
 public static function upload_data($userid, $file_data, $session, $offset)
 {
     $expired = time() + self::EXPIRED_SECONDS;
     $url = self::generateResUrl($userid);
     $sign = Auth::appSign($url, $expired);
     $data = array('FileContent' => $file_data, 'op' => 'upload_slice', 'session' => $session, 'offset' => $offset);
     $req = array('url' => $url, 'method' => 'post', 'timeout' => 10, 'data' => $data, 'header' => array('Authorization:' . $sign));
     $rsp = Http::send($req);
     $info = Http::info();
     $ret = json_decode($rsp, true);
     if ($ret) {
         if (0 === $ret['code']) {
             $ret['httpcode'] = $info['http_code'];
             return $ret;
         } else {
             return array('httpcode' => $info['http_code'], 'code' => $ret['code'], 'message' => $ret['message'], 'data' => array());
         }
     } else {
         return array('httpcode' => $info['http_code'], 'code' => self::VIDEO_NETWORK_ERROR, 'message' => 'network error', 'data' => array());
     }
 }
Example #2
0
 private static function statBase($bucketName, $path)
 {
     $path = self::cosUrlEncode($path);
     $expired = time() + self::EXPIRED_SECONDS;
     $url = self::generateResUrl($bucketName, $path);
     $sign = Auth::appSign($expired, $bucketName);
     $data = array('op' => 'stat');
     $url = $url . '?' . http_build_query($data);
     $req = array('url' => $url, 'method' => 'get', 'timeout' => self::$timeout, 'header' => array('Authorization:' . $sign));
     return self::sendRequest($req);
 }
    $expired = time() + Cosapi::EXPIRED_SECONDS;
    $sign = Auth::appSign($expired, $bucketname);
    //$url='location:'.$_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment']."?sign={$sign}";
    //echo "url:{$url}<br/>";
    dheader('location:' . $_G['setting']['ftp']['attachurl'] . 'forum/' . $attach['attachment'] . "?sign={$sign}");
}
/*
 * 此处为我自己写的代码,为了实现远程附件的下载
 * 龚成
 * 2016-3-3
 */
if ($attach['remote'] && !$_G['setting']['ftp']['hideurl']) {
    //dheader('location:'.$_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment']);
    $bucketname = "discuz";
    $expired = time() + Cosapi::EXPIRED_SECONDS;
    $sign = Auth::appSign($expired, $bucketname);
    $url = 'location:' . $_G['setting']['ftp']['attachurl'] . 'forum/' . $attach['attachment'] . "?sign={$sign}";
    //echo "url:{$url}<br/>";
    dheader('location:' . $_G['setting']['ftp']['attachurl'] . 'forum/' . $attach['attachment'] . "?sign={$sign}");
}
/*
 * 以上为我自己写的代码,为了实现远程附件的下载
 */
$filesize = !$attach['remote'] ? filesize($filename) : $attach['filesize'];
$attach['filename'] = '"' . (strtolower(CHARSET) == 'utf-8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($attach['filename']) : $attach['filename']) . '"';
dheader('Date: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
dheader('Last-Modified: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
dheader('Content-Encoding: none');
if ($isimage && !empty($_GET['noupdate']) || !empty($_GET['request'])) {
    dheader('Content-Disposition: inline; filename=' . $attach['filename']);
} else {
Example #4
0
 /**
  * @param $url 图片url
  * @return 返回的结果,JSON字符串,字段参见API文档
  */
 public static function imagetagurl($url)
 {
     $expired = time() + self::EXPIRED_SECONDS;
     $postUrl = Conf::$END_POINT . 'youtu/imageapi/imagetag';
     $sign = Auth::appSign($expired, Conf::$USER_ID);
     $post_data = array("app_id" => Conf::$APPID, "url" => $url);
     $req = array('url' => $postUrl, 'method' => 'post', 'timeout' => 10, 'data' => json_encode($post_data), 'header' => array('Authorization:' . $sign, 'Content-Type:text/json', 'Expect: '));
     $rsp = Http::send($req);
     $ret = json_decode($rsp, true);
     if (!$ret) {
         return self::getStatusText();
     }
     return $ret;
 }
Example #5
0
 /**
  * @brief getfaceinfo
  * @param face_id 待查询的人脸id
  * @param rsp 返回的人脸信息查询结果,JSON字符串,字段参见API文档
  * @return 返回的结果,JSON字符串,字段参见API文档
  */
 public static function getfaceinfo($face_id)
 {
     $expired = time() + self::EXPIRED_SECONDS;
     $url = Conf::API_YOUTU_END_POINT . 'youtu/api/getfaceinfo';
     $sign = Auth::appSign($expired, Conf::$USER_ID);
     $post_data = array("app_id" => Conf::$APPID, "face_id" => $face_id);
     $req = array('url' => $url, 'method' => 'post', 'timeout' => 10, 'data' => json_encode($post_data), 'header' => array('Authorization: ' . $sign));
     $rsp = Http::send($req);
     $ret = json_decode($rsp, true);
     return $ret;
 }
Example #6
0
 public static function del($fileid, $userid = 0)
 {
     if (!$fileid) {
         return array('httpcode' => 0, 'code' => self::IMAGE_PARAMS_ERROR, 'message' => 'params error', 'data' => array());
     }
     $expired = time() + self::EXPIRED_SECONDS;
     $url = self::generateResUrl($userid, $fileid, 'del');
     $sign = Auth::appSign($url, $expired);
     $req = array('url' => $url, 'method' => 'post', 'timeout' => 10, 'header' => array('Authorization:QCloud ' . $sign));
     $rsp = Http::send($req);
     $info = Http::info();
     $ret = json_decode($rsp, true);
     if ($ret) {
         if (0 === $ret['code']) {
             return array('httpcode' => $info['http_code'], 'code' => $ret['code'], 'message' => $ret['message'], 'data' => array());
         } else {
             return array('httpcode' => $info['http_code'], 'code' => $ret['code'], 'message' => $ret['message'], 'data' => array());
         }
     } else {
         return array('httpcode' => $info['http_code'], 'code' => self::IMAGE_NETWORK_ERROR, 'message' => 'network error', 'data' => array());
     }
 }