|
|
|
@ -15,6 +15,7 @@ import com.elink.esua.epdc.cloud.OssFactory; |
|
|
|
import com.elink.esua.epdc.commons.tools.annotation.LogOperation; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.CompressImgUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.validator.group.AliyunGroup; |
|
|
|
@ -154,20 +155,24 @@ public class OssController { |
|
|
|
String[] base64ImgArr = formDTO.getBase64String().split(","); |
|
|
|
String suffixTmp = base64ImgArr[0]; |
|
|
|
String suffix = suffixTmp.substring(11, suffixTmp.indexOf(";")); |
|
|
|
byte[] imgBytes = new BASE64Decoder().decodeBuffer(base64ImgArr[1]); |
|
|
|
byte[] bytes = new BASE64Decoder().decodeBuffer(base64ImgArr[1]); |
|
|
|
// 图片压缩
|
|
|
|
byte[] imgBytes = CompressImgUtils.commpressPicCycle(bytes, 100, 0.5); |
|
|
|
String url = OssFactory.build().uploadSuffix(imgBytes, suffix); |
|
|
|
return new Result<String>().ok(url); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("uploadFile") |
|
|
|
public Result<String> uploadFile(@RequestBody UploadToOssDTO dto) { |
|
|
|
public Result<String> uploadFile(@RequestBody UploadToOssDTO dto) throws Exception { |
|
|
|
byte[] fileByte = dto.getFileByte(); |
|
|
|
if (null == fileByte || fileByte.length == NumConstant.ZERO) { |
|
|
|
return new Result().error(ModuleErrorCode.UPLOAD_FILE_EMPTY); |
|
|
|
} |
|
|
|
// 图片压缩
|
|
|
|
byte[] imgBytes = CompressImgUtils.commpressPicCycle(fileByte, 100, 0.5); |
|
|
|
//上传文件
|
|
|
|
String extension = FilenameUtils.getExtension(dto.getFileName()); |
|
|
|
String url = OssFactory.build().uploadSuffix(fileByte, extension); |
|
|
|
String url = OssFactory.build().uploadSuffix(imgBytes, extension); |
|
|
|
|
|
|
|
return new Result().ok(url); |
|
|
|
} |
|
|
|
|