Gus
Gus

Reputation: 4517

play framework (2.3) - Getting asset URL from controller

I'm using iText to generate a PDF file in a controller, but I need to insert an image from the public assets in the file using it's URL. Is there any way to get the asset URL from the controller?

Upvotes: 1

Views: 1218

Answers (1)

Daniel Olszewski
Daniel Olszewski

Reputation: 14401

Reverse routing works for assets just like for controllers. This should provide you with required information:

controllers.routes.Assets.at("images/unchecked.png").absoluteURL(request())

You can read more about it in the section Reverse routing for public assets of the documentation.

Upvotes: 1

Related Questions