图片base64大小限制
This commit is contained in:
@@ -362,7 +362,13 @@ public class ARMerchantManager {
|
|||||||
log.error("图片大小超过2MB,请重新上传");
|
log.error("图片大小超过2MB,请重新上传");
|
||||||
throw new RuntimeException("图片大小超过2MB,请重新上传");
|
throw new RuntimeException("图片大小超过2MB,请重新上传");
|
||||||
}
|
}
|
||||||
return Base64.getEncoder().encodeToString(IOUtils.toByteArray(url.openStream()));
|
String base64String = Base64.getEncoder().encodeToString(IOUtils.toByteArray(url.openStream()));
|
||||||
|
double base64SizeInMB = base64String.length() / (1024.0 * 1024.0);
|
||||||
|
if (base64SizeInMB > 2) {
|
||||||
|
log.error("图片base64大小超过2MB,请重新上传");
|
||||||
|
throw new RuntimeException("图片base64大小超过2MB,请重新上传");
|
||||||
|
}
|
||||||
|
return base64String;
|
||||||
}catch (IOException e){
|
}catch (IOException e){
|
||||||
log.error("图片转base64失败:{}",e.getMessage());
|
log.error("图片转base64失败:{}",e.getMessage());
|
||||||
throw new RuntimeException("图片转base64失败");
|
throw new RuntimeException("图片转base64失败");
|
||||||
|
|||||||
Reference in New Issue
Block a user