簡體   English   中英

如何在Play框架下指定其他附件路徑

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM