I am new to play framework - (Java version). We are porting a legacy application which use asset folder from different location. say...
asset location:
/home/user/other/asset/location/upload
play location
/home/user/some/play/location
In the routes file, there are ...
GET /assets/*file controllers.Assets.at(path="/public", file)
GET /upload/*file controllers.Assets.at(path="/home/user/other/asset/location/upload", file)
In (SBT) build.sbt file...
unmanagedResourceDirectories in Assets += baseDirectory.value / "/home/user/other/asset/location/upload"
I am using like this...
public class AssetHelper
{
public static final String ASSET = "/public";
public static final String UPLOAD = "/home/user/other/asset/location/upload";
}
In user profile view...
<img src="@routes.Assets.at(AssetHelper.UPLOAD,"userprofile/12345/profilepic/imgo.jpeg")" alt="SomeImage"/>
Normal css and javascript...
<img class="logo" src="@routes.Assets.at(AssetHelper.ASSET,"dist/css/images/logo.png")" alt="LOGO">
I want to include other location assets, how can I do that? Can you explain build.sbt 's given params, as don't know scala yet?
Asset controller from Play Framework's core can only serve files that was bundled in application jar's. You have to write you own controller if you want to return static files from filesystem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.