How Lagom java use Play Java Controller

Lagom 1.3.x for java

user Play java Controller download file

public class FileController extends Controller {

  /**
   * download
   * @param f filename
   * @return Result
   * @throws FileNotFoundException
   */
  public Result download(String f) throws FileNotFoundException {
    final InputStream is = new BufferedInputStream(new FileInputStream(f));
    return ok(is).withHeader("Content-Disposition", "attachment; filename=1.txt");
  }

}

routes file

GET    /api/files  ytd.pdnms.controllers.FileController.download(f: String)
->     /           com.lightbend.lagom.javadsl.server.LagomServiceRouter

Hi @yangjun,

this is a great contribution. The case you describe is not very common but it comes up quite often and, unfortunately, it’s not very documented.

We developed an example application to demonstrate how to handle file upload (in scala dsl) byt combining a Play controller in Lagom.

It’s in https://github.com/lagom/lagom-recipes/tree/master/file-upload/file-upload-scala-sbt. I’ll leave the link here so it can be located too.

Thanks!

I see exampe, how do used java? demo is scala.
thanks.

Hi @yangjun,
Have you find the answer to your question how to upload file in Lagom service with java?