【问题标题】:How can i specify a different attachments path under play framework如何在播放框架下指定不同的附件路径
【发布时间】:2012-01-10 16:48:27
【问题描述】:

我现在正在使用play框架,我已经知道我们可以在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();
}

【问题讨论】:

    标签: java playframework


    【解决方案1】:

    我会创建一个扩展当前 blob.class (http://www.playframework.org/documentation/api/1.2.4/play/db/jpa/Blob.html) 的类,并重新实现 getStore( ) 方法来读取与 attachments.path 不同的属性(即 avatar.path)。

    祝你好运!

    【讨论】:

      猜你喜欢
      • 2015-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      • 1970-01-01
      • 1970-01-01
      • 2011-11-09
      相关资源
      最近更新 更多