Jippe Holwerda
10/14/2022, 11:14 AMprivate fun writeToDisk(part: StreamingPart, bytes: ByteArray, length: Int) =
File.createTempFile(part.fileName ?: UUID.randomUUID().toString()
+ "-", ".tmp", temporaryFileDirectory).apply {
deleteOnExit()
FileOutputStream(this).apply {
write(bytes, 0, length)
use { part.inputStream.copyTo(it, writeToDiskThreshold) }
}
}
with the deleteOnExit()
call.
We want to keep the file around even when the JVM exits (we're running on k8s so pods can always be killed).
Would it be a good idea to make this behaviour configurable, i.e. through a flag that is passed from MultipartFormBody.from
to the MultipartFormParser
?
If so, I'll make a merge request... Happy to hear your thoughts.Jippe Holwerda
10/14/2022, 12:45 PMJippe Holwerda
10/14/2022, 3:05 PMJippe Holwerda
10/17/2022, 7:54 AM