|
|
@@ -82,4 +82,38 @@ class QiniuService extends BaseService
|
|
|
return $this->host . '/' . $filename;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询
|
|
|
+ * @param $no 快递单号
|
|
|
+ * @param string $phone // 手机号
|
|
|
+ * @param string $code 快递公司编号
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function uploadBase64($filename,$base64)
|
|
|
+ {
|
|
|
+ // 配置参数
|
|
|
+ if(empty($this->accessKey) || empty($this->secretKey) || empty($this->bucket) || empty($this->host)){
|
|
|
+ $this->error = 'QINIU接口参数未配置';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 初始化鉴权对象
|
|
|
+ $auth = new Auth($this->accessKey, $this->secretKey);
|
|
|
+
|
|
|
+ // 生成上传策略
|
|
|
+ $policy = null;
|
|
|
+ $uptoken = $auth->uploadToken($this->bucket, $filename, 3600, $policy);
|
|
|
+
|
|
|
+ // 初始化 UploadManager 对象并进行文件上传
|
|
|
+ $uploadMgr = new UploadManager();
|
|
|
+ list($ret, $err) = $uploadMgr->put($uptoken, $filename, $base64,'');
|
|
|
+
|
|
|
+ if ($err !== null) {
|
|
|
+ $this->error = 'QINIU图片上传失败:' . $err->getMessage();
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return $this->host . '/' . $filename;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|