刚刚看见好像有相同的问题,但是我试了一下并没有解决。
就是这个方法里边的log:
@AdaptBy(type=UploadAdaptor.class, args={"${app.root}/WEB-INF/tmp/user_avatar", "8192", "utf-8", "20000", "102400"})
@POST
@Ok(">>:/user/profile")
@At("/avatar")
public void uploadAvatar(@Param("file")TempFile tf,
@Attr(scope=Scope.SESSION, value="me")int userId,
AdaptorErrorContext err) {
String msg = null;
if (err != null && err.getAdaptorErr() != null) {
msg = "文件大小不符合规定";
} else if (tf == null) {
msg = "空文件";
} else {
UserProfile profile = get(userId);
try {
BufferedImage image = Images.read(tf.getFile());
image = Images.zoomScale(image, 128, 128, Color.WHITE);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Images.writeJpeg(image, out, 0.8f);
profile.setAvatar(out.toByteArray());
dao.update(profile, "^avatar$");
} catch(DaoException e) {
log.info("System Error", e);
msg = "系统错误";
} catch (Throwable e) {
msg = "图片格式错误"; }
}
if (msg != null)
Mvcs.getHttpSession().setAttribute("upload-error-msg", msg);
}
}