Robert Jaros
04/22/2020, 1:59 PMzipFile.delete()
? Currently I have this:
suspend fun download(request: ServerRequest): ServerResponse {
val zipFile = // get the temporary <http://java.io|java.io>.File from a different service
ServerResponse.ok().contentLength(zipFile.length())
.contentType(MediaType.parseMediaType("application/zip"))
.header("Content-Disposition", "attachment; filename=\"file.zip\"")
.bodyValueAndAwait(FileSystemResource(zipFile))
}
Is there any callback I can use? I don't want to read the file into temporary ByteArray
.Robert Jaros
04/22/2020, 2:07 PMjava.nio.file.NoSuchFileException
) :
suspend fun download(request: ServerRequest): ServerResponse {
val zipFile = // get the temporary <http://java.io|java.io>.File from a different service
val reponse = ServerResponse.ok().contentLength(zipFile.length())
.contentType(MediaType.parseMediaType("application/zip"))
.header("Content-Disposition", "attachment; filename=\"file.zip\"")
.bodyValueAndAwait(FileSystemResource(zipFile))
zipFile.delete()
response
}
Dennis Schröder
04/22/2020, 2:17 PM.bodyValueAndAwait(FileSystemResource(zipFile)).also { zipFile.delete() }
Robert Jaros
04/22/2020, 2:25 PMRobert Jaros
04/22/2020, 2:26 PMRobert Jaros
04/22/2020, 2:30 PMRobert Jaros
04/22/2020, 4:04 PM.bodyValueAndAwait(FileSystemResource(zipFile)).also {
GlobalScope.launch {
delay(5000)
zipFile.delete()
}
}
Dennis Schröder
04/22/2020, 4:16 PMRobert Jaros
04/22/2020, 5:01 PM