| xqd
@@ -4,7 +4,7 @@
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
|
-use App\Services\OssService;
|
|
|
+use App\Services\OSS;
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
class UploadController extends Controller
|
| xqd
@@ -17,13 +17,13 @@ class UploadController extends Controller
|
|
|
//获取上传图片的临时地址
|
|
|
$tmppath = $file->getRealPath();
|
|
|
//生成文件名
|
|
|
- $fileName = rand(1000,9999) . time() .date('ymd') . '.' . $file->getClientOriginalExtension();
|
|
|
+ $fileName = rand(1000,9999). time() .date('ymd') . '.' . $file->getClientOriginalExtension();
|
|
|
//拼接上传的文件夹路径(按照日期格式1810/17/xxxx.jpg)
|
|
|
$pathName = 'chengluApp/'.date('Y-m/d').'/'.$fileName;
|
|
|
//上传图片到阿里云OSS
|
|
|
- OssService::publicUpload(env('ALI_OSS_BUCKET'), $pathName, $tmppath, ['ContentType' => $file->getClientMimeType()]);
|
|
|
+ OSS::publicUpload(env('ALI_OSS_BUCKET'), $pathName, $tmppath, ['ContentType' => $file->getClientMimeType()]);
|
|
|
//获取上传图片的Url链接
|
|
|
- $Url = OssService::getPublicObjectURL(env('ALI_OSS_BUCKET'), $pathName);
|
|
|
+ $Url = OSS::getPublicObjectURL(env('ALI_OSS_BUCKET'), "");
|
|
|
}catch (\Exception $exception){
|
|
|
return $this->response->errorForbidden($exception->getMessage());
|
|
|
}
|