I want to add a simple button to my application that, when clicked, will trigger an action that will create a csv file from the two lists that I have, and upload it to the user's computer.
This is my action:
def createAndDownloadFile = Action {
val file = new File("newFile.csv")
val writer = CSVWriter.open(file)
writer.writeAll(List(listOfHeaders, listOfValues))
writer.close()
Ok.sendFile(file, inline = false, _ => file.getName)
}
but now it works for me, the file does not load from the browser ...
im, expecting the file to load by the browser, I thought I Ok.sendFileshould do the trick.
thank!
source
share