[英]How can i specify a different attachments path under play framework
我现在正在使用播放框架,我已经知道我们可以在application.conf中指定附件路径:
# Store path for Blob content
attachments.path=data/attachments
我的应用程序具有不同类型的图片,我需要将这些图片分成不同的目录。
我该如何实现我的想法?
非常感谢!
这是我的控制器代码:
public static void uploadAvatar(Blob file){
if(request.isNew){
Long userId = Long.parseLong(session.get(Constants.USER_ID_IN_SESSION));
User user = User.findById(userId);
// Delete old picture
if (user.avatar.getFile() != null) {
user.avatar.getFile().delete();
}
user.avatar = file;
user.avatarFileName = file.getFile().getName();
user.save();
}
Users.settings();
}
我将创建一个扩展当前blob.class(http://www.playframework.org/documentation/api/1.2.4/play/db/jpa/Blob.html)的类,然后将getStore()方法重新实现为读取与attachments.path(即avatar.path)不同的属性。
祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.