Init Repo

This commit is contained in:
root
2019-09-06 23:53:10 +08:00
commit f0ef89dfbb
7905 changed files with 914138 additions and 0 deletions

View File

@ -0,0 +1,77 @@
<?php
namespace wstmart\common\model;
/**
* ============================================================================
* 基础控业务处理
*/
use think\Model;
use think\Db;
vendor('oss-sdk.autoload');
use OSS\OssClient;
use OSS\Core\OssException;
const OSS_ACCESS_ID = 'LTAIfppBmzIHRPV0';
const OSS_ACCESS_KEY = 'OdsoQBa30zzPC38Jq9EmefbqSgFZnX';
const OSS_ENDPOINT = 'oss-cn-hongkong.aliyuncs.com';
const OSS_BUCKET = 'qlgmall';
const OSS_WEB_SITE = 'img.zgqlg.com.cn';
class Aliyunoss extends Model {
public $ossClient;
private $oss_access_id;
private $oss_access_key;
private $oss_endpoint;
private $oss_bucket;
private $oss_web_site;
public function __construct(){
parent::__construct();
$this->oss_access_id = OSS_ACCESS_ID;
$this->oss_access_key = OSS_ACCESS_KEY;
$this->oss_endpoint = OSS_ENDPOINT;
$this->oss_bucket = OSS_BUCKET;
$this->oss_web_site = OSS_WEB_SITE;
$this->ossClient = new OssClient($this->oss_access_id,$this->oss_access_key,$this->oss_endpoint);
}
/**
* [getInfo 获取图片信息]
* @param [type] $object [oss图片名]
* @return [type] [description]
*/
public function getInfo($object){
$options = array(
//不能 加入这个OssClient::OSS_FILE_DOWNLOAD如果加入会下载下来
// OssClient::OSS_FILE_DOWNLOAD =>'upload/image/2018-06/5b1b478de0a8123.jpg',
OssClient::OSS_PROCESS => "image/info", );
$rs = $this->ossClient->getObject($this->oss_bucket, $object,$options);
return json_decode($rs,true);
die;
}
/**
* [uploadFile 图片上传]
* @param [type] $object [上传后的文件名]
* @param [type] $file [上传前的文件路径]
* @return [type] [description]
*/
public function uploadFile($object,$file){
try{
$this->ossClient->uploadFile($this->oss_bucket, $object,$file);
return true;
}catch(OssException $e){
$e->getMessage();
return false;
}
}
/**
* [del 删除文件]
* @param [type] $object [oss文件名包含路径]
* @return [type] [description]
*/
public function del($object){
try{
$this->ossClient->deleteObject($this->oss_bucket,$object);
}catch(OssException $e){
return $e->getMessage();
}
}
}