Asset mapping outside public folder on Play framework

后端 未结 4 1211
悲哀的现实
悲哀的现实 2021-01-18 20:26

We have huge list of images that we need to store in an external path.. i.e outside of play application folder.

How can we make it available to play as an asset so i

4条回答
  •  梦毁少年i
    2021-01-18 20:35

    A hacky solution would be to include in your sbt play public folder a symlink to the location you want to load the files. The symlink will be packaged in the assembly and will be functional at run time.

    cd ~/your/playframework/awesome/project/public
    ln -s '/var/lib/funky-data-set-for-my-awesome-project/' funky-data
    

    Now you can use in your routes file something like:

    GET         /funky/assets/*file                controllers.Assets.at(path="/public/funky-data", file)
    

    The downside of this is that your stage/dev/prod environment must have that content you need at the same location.

提交回复
热议问题