Commit d959721f authored by wujiang's avatar wujiang

修改上传

parent d14645b7
......@@ -222,11 +222,22 @@ public class UnitInfoController extends BaseController {
if (ValidationUtil.isEmpty(file)) {
throw new BadRequest("参数校验失败.");
}
/// List<String> NOT_ALLOWED_TYPES =Arrays.asList("text/html");
// 只支持图片类型
List<String> ALLOWED_TYPES =Arrays.asList("jpg","jpeg","png");
//只支持图片类型
if (file.getContentType() == null || !file.getContentType().startsWith("image/")) {
throw new BadRequest("只支持图片类型上传");
throw new BadRequest("只支持jpg,jpeg,png图片类型上传");
}
//判断文件后缀
String filename = file.getName();
String extension = filename.substring(filename.lastIndexOf('.') + 1).toLowerCase();
if(!ALLOWED_TYPES.contains(extension))
{
throw new BadRequest("只支持jpg,jpeg,png图片类型上传");
}
//判断文件大小10M
if (file.getSize() > 10 * 1024 * 1024) {
throw new BadRequest("上传文件大小不超过10M");
}
RequestContext.setAppKey("AMOS_STUDIO");
RequestContext.setProduct("AMOS_STUDIO_WEB");
RequestContext.setToken(requestContext.getToken());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment