本地生活商品图片上传到阿里云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()
{
try{
dump($this->request->post());
die;
// $result = UploadAliOSS::uploadImage();
// if ($result['code'] == 1) {
// return JsonServer::success('上传成功', $result['data']);
// }
// return JsonServer::error('上传失败');
$post = $this->request->post();
if (is_array(self::$APP_UPLOAD_PATH[$post['type']])) {
$path = self::$APP_UPLOAD_PATH[$post['type']];
// 本地生活商家上传商品
if ($post['type'] === 'local_shop_add' && $post['lstore_id'] > 0) {
$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) {
return JsonServer::error($e->getMessage());
}