|
|
|
@@ -2,8 +2,10 @@ package com.iformall.controller.sys; |
|
|
|
|
|
|
|
import com.iformall.annotation.SystemControllerLog; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.controller.base.BaseController; |
|
|
|
import com.iformall.domain.dto.UploadBase64DTO; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.file.aliyun.AliyunOSS; |
|
|
|
import com.iformall.ueditor.define.FileType; |
|
|
|
@@ -215,11 +217,22 @@ public class UploadController extends BaseController { |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("base64Upload") |
|
|
|
@PostMapping("base64Upload") |
|
|
|
public ResultData base64Upload(String content) { |
|
|
|
@PostMapping("/base64Upload") |
|
|
|
public ResultData base64Upload(@RequestBody UploadBase64DTO uploadReq) { |
|
|
|
if (null == uploadReq || StringUtils.isBlank(uploadReq.getContent())) { |
|
|
|
return new ResultData(Result.ERROR,"base64内容为空"); |
|
|
|
} |
|
|
|
TenantEntity tenantEntity = getTenantInfo(); |
|
|
|
String content = uploadReq.getContent(); |
|
|
|
String suffix = "JPG"; |
|
|
|
if (content.contains(";")) { |
|
|
|
suffix = content.split(";")[0].split("/")[1]; |
|
|
|
content = content.split(",")[1]; |
|
|
|
} |
|
|
|
byte[] fileBytes = Base64.decodeBase64(content); |
|
|
|
String suffix = FileType.getSuffix("JPG"); |
|
|
|
if (null == fileBytes || fileBytes.length <= 0 ) { |
|
|
|
return new ResultData(Result.ERROR,"base64内容非法"); |
|
|
|
} |
|
|
|
ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), suffix, fileBytes); |
|
|
|
return data; |
|
|
|
} |
|
|
|
|