|
|
@@ -98,11 +98,21 @@ class UploadController extends Backend
|
|
|
}
|
|
|
$fileName = 'image_'.md5($uuid? $uuid : $base64) . '.jpeg';
|
|
|
$base64 = str_replace('data:image/jpeg;base64,','',$base64);
|
|
|
- file_put_contents($fileDir.'/'.$fileName, base64_decode($base64));
|
|
|
- if(file_exists($fileDir.'/'.$fileName)){
|
|
|
+
|
|
|
+ $driver = \App\Services\ConfigService::make()->getConfigByCode('file_upload_driver','local');
|
|
|
+ if($driver == 'qiniu') {
|
|
|
$filePath = str_replace(ATTACHMENT_PATH, '', $fileDir) . '/' . $fileName;
|
|
|
- return message(MESSAGE_OK, true, ['url'=>get_image_url($filePath, false),'path'=>$filePath]);
|
|
|
+ if($path = \App\Services\QiniuService::make()->uploadBase64($filePath, base64_decode($base64))){
|
|
|
+ return message(MESSAGE_OK, true, ['url'=>$path,'path'=>$path]);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ file_put_contents($fileDir.'/'.$fileName, base64_decode($base64));
|
|
|
+ if(file_exists($fileDir.'/'.$fileName)){
|
|
|
+ $filePath = str_replace(ATTACHMENT_PATH, '', $fileDir) . '/' . $fileName;
|
|
|
+ return message(MESSAGE_OK, true, ['url'=>get_image_url($filePath, false),'path'=>$filePath]);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return message(MESSAGE_FAILED, false);
|