andyg
11/14/2020, 1:38 AMstatic
because there's some validation involved (or maybe file created dynamically). Based on an earlier Slack thread, I came up with this:
return if (<some validation code here>)
Response(Status.OK)
.header("Content-Type", "application/zip") // "application/octet-stream")
.header("Content-Disposition", "attachment; filename=${myFileToServe.file.substringAfterLast("/")}")
.header("Content-Length", myFileToServe.openConnection().contentLength.toString())
.body(myFileToServe.openStream())
else Response(Status.UNAUTHORIZED)
dave
11/14/2020, 1:16 PMdave
11/14/2020, 1:17 PMandyg
11/15/2020, 6:32 AM15mb of 60mb (25%)
, other times it doesn't report the full size. I assumed knowing the full size and percentage was only possible when content-length is specified. don't know for sure but doesn't seem to hurt adding it in