本地生活商品图片上传到阿里云OSS

This commit is contained in:
wangxiaowei 2024-08-21 10:53:14 +08:00
parent dd21aba648
commit 79e92d7aa8

@ -61,13 +61,25 @@ class File extends Api
public function aliOSS() public function aliOSS()
{ {
try{ try{
dump($this->request->post()); $post = $this->request->post();
die; if (is_array(self::$APP_UPLOAD_PATH[$post['type']])) {
// $result = UploadAliOSS::uploadImage(); $path = self::$APP_UPLOAD_PATH[$post['type']];
// if ($result['code'] == 1) {
// return JsonServer::success('上传成功', $result['data']); // 本地生活商家上传商品
// } if ($post['type'] === 'local_shop_add' && $post['lstore_id'] > 0) {
// return JsonServer::error('上传失败'); $path .= '/' . $post['lstore_id'];
} else {
return JsonServer::error('缺少参数');
}
$result = UploadAliOSS::uploadImage($path);
if ($result['code'] == 1) {
return JsonServer::success('上传成功', $result['data']);
}
return JsonServer::error('上传失败');
} else {
return JsonServer::error('上传文件类型不存在');
}
}catch(\Exception $e) { }catch(\Exception $e) {
return JsonServer::error($e->getMessage()); return JsonServer::error($e->getMessage());
} }