Shakil Ahmed
Shakil Ahmed

Reputation: 1521

Play Framework 2.3.x external asset / upload folder

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?

Upvotes: 0

Views: 748

Answers (1)

user815114
user815114

Reputation: 118

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.

Upvotes: 1

Related Questions