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 = TencentyunAuth::appSign($url, $expired); $req = array('url' => $url, 'method' => 'post', 'timeout' => 10, 'header' => array('Authorization:QCloud ' . $sign)); $rsp = TencentyunHttp::send($req); $info = TencentyunHttp::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()); } }
/** * 上传文件流 * @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 = TencentyunAuth::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 = TencentyunHttp::send($req); $info = TencentyunHttp::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()); } }