2 引用sdk`
require_once ROOT_PATH.'/vendor/oss-sdk/autoload.php
3 公共参数
protected $accessKeyId = '*****************';
protected $accessKeySecret = '****************************';
protected $endpoint = 'http://oss-cn-hangzhou.aliyuncs.com/';
protected $bucket = '*******';
4 我是在fastadmin的上传图片代码中改
public function videoUpload()
{
$attachment = null;
//默认普通上传文件
$file = $this->request->file('file');
try {
$upload = new Upload($file);
$attachment = $upload->upload();
// 本地文件
$lcoalfile = ROOT_PATH.'public'.$attachment->url;
require_once ROOT_PATH.'/vendor/oss-sdk/autoload.php';
$ossClient = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint);
$object = $attachment->filename;
$options = array(
OssClient::OSS_CHECK_MD5 => true,
OssClient::OSS_PART_SIZE => 1,
);
$ossClient->multiuploadFile($this->bucket, $object, $lcoalfile, $options);
} catch (UploadException $e) {
$this->error($e->getMessage());
}