Fixed setting file extension and deleting file on exit

This commit is contained in:
dankito 2024-11-21 18:36:04 +01:00
parent da84aaedf6
commit 2b3c3fa5fa
1 changed files with 2 additions and 1 deletions

View File

@ -122,8 +122,9 @@ class MailReader(
if (invoice != null) {
val filename = File(part.fileName)
val file = File.createTempFile(filename.nameWithoutExtension, filename.extension).also { file ->
val file = File.createTempFile(filename.nameWithoutExtension, "." + filename.extension).also { file ->
part.inputStream.use { it.copyTo(file.outputStream()) }
file.deleteOnExit()
}
return MailAttachmentWithEInvoice(part.fileName, mediaType, invoice, file)