Skip to content

Commit 19c5db3

Browse files
committed
Simplified bytes copy
1 parent 749cca4 commit 19c5db3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/kotlin/server/request/MultipartExtensions.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package server.request
22

33
import io.ktor.http.content.PartData
4+
import io.ktor.utils.io.jvm.javaio.copyTo
45
import io.ktor.utils.io.readBuffer
56
import java.io.File
67
import java.io.IOException
@@ -27,10 +28,8 @@ suspend fun PartData.FileItem.save(rootDir: File, uuid: UUID? = null, overwrite:
2728
targetFile.delete()
2829
}
2930

30-
provider().readBuffer().use { input ->
31-
targetFile.outputStream().use { output ->
32-
input.copyTo(output)
33-
}
31+
targetFile.outputStream().use { output ->
32+
provider().copyTo(output)
3433
}
3534

3635
return targetFile

0 commit comments

Comments
 (0)