2012-01-06 69 views
0

我使用的是發揮框架現在,我已經知道了,我們可以指定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(); 
} 

回答

0

我會做它擴展了當前blob.class類(http://www.playframework.org/documentation/api/1.2.4/play/ db/jpa/Blob.html),並重新實現getStore()方法來讀取不同於attachments.path(即avatar.path)的屬性。

祝你好運!