简体   繁体   English

Play Framework 2.3.x外部资产/上载文件夹

[英]Play Framework 2.3.x external asset / upload folder

I am new to play framework - (Java version). 我是玩框架的新手-(Java版本)。 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... 在(SBT)build.sbt文件中...

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... 普通的CSS和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? 您可以解释build.sbt的给定参数,因为还不知道scala吗?

Asset controller from Play Framework's core can only serve files that was bundled in application jar's. Play Framework核心的资产控制器只能提供捆绑在应用程序jar中的文件。 You have to write you own controller if you want to return static files from filesystem. 如果要从文件系统返回静态文件,则必须编写自己的控制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM