Skip to content

Instantly share code, notes, and snippets.

@jefisu
Created July 26, 2022 01:56
Show Gist options
  • Save jefisu/0fbc693a11325bf3097ed647ad50b7ac to your computer and use it in GitHub Desktop.
Save jefisu/0fbc693a11325bf3097ed647ad50b7ac to your computer and use it in GitHub Desktop.
import io.ktor.http.content.*
import java.io.File
fun PartData.FileItem.save(path: String, fileName: String) {
val fileBytes = streamProvider().readBytes()
val folder = File(path)
folder.mkdir()
File("$path$fileName").writeBytes(fileBytes)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment