laravel阿里云oss扩展,在阿里云官方oss sdk上集成了policy接口,方便前端直传
$policy = Oss::policy($phone, $templateCode, $params);
// policy 结构如下
Array
(
'accessid' => 'ALI_OSS_ACCESS_KEY_ID',
'url' => 'https://ALI_OSS_BUCKET.ALI_OSS_ENDPOINT',
'policy' => 'eyJleHBpcmF0aW9uIjoiMjAxOS0wNi0wNlQxMDoxMjozNVoiLCJjb25kaXRpb25zIjpbWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCwyMDk3MTUyMF0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJkZXZcLzIwMTkwNlwvMDYiXV19',
'signature' => 'HIijmFun1561CU+i1Ltl/X6tIC8=',
'expire' => 1559815955,
'dir' => 'dev/20190606',
);
// $object为oss对象名,如 image/a.jpg
$url = Oss::url($object);
调用url方法后$url为:https://ALI_OSS_BUCKET.ALI_OSS_ENDPOINT/image/a.jpg
// $object为oss对象名,如 image/a.jpg; $path为本地服务器路径
$url = Oss::saveObjTo($object, $path);