Skip to main content
David Cruz Anaya

David Cruz Anaya

Senior Android & Kotlin Multiplatform Engineer

  • Home
  • About
  • Portfolio
  • Book
  • Speaking
  • Blog
  • Flashcards
  • Nomad Life
  • Contact
Visit Vectencia Shop

Follow Me

Privacy Policy

2014 - 2026 © davthecoder is trading as Vectencia Ltd.

davthecoder
davthecoder.com
davthecoder × Vectencia
🖥️

Ktor Server Gotchas

Find the bugs in each code snippet

File Upload Handler1 P03 total
1/4
1fun Application.configureRouting() {
2 routing {
3 post("/upload") {
4 val multipart = call.receiveMultipart()
5 var fileName = ""
6
7 multipart.forEachPart { part ->
8 when (part) {
9 is PartData.FileItem -> {
10 fileName = part.originalFileName ?: "upload"
11 val file = File("/uploads/$fileName")
12 file.outputStream().use { output ->
13 part.streamProvider().copyTo(output)
14 }
15 }
16 else -> {}
17 }
18 part.dispose()
19 }
20
21 call.respondText("Uploaded: $fileName")
22 }
23 }
24}
Click on the lines you think have bugsFound 0 of 3
←→NavigateAShow remainingRReset
🎯Bug Formula: What's wrong → What breaks for the user → The fix → The trade-off
Skip to main content
David Cruz Anaya

David Cruz Anaya

Senior Android & Kotlin Multiplatform Engineer

  • Home
  • About
  • Portfolio
  • Book
  • Speaking
  • Blog
  • Flashcards
  • Nomad Life
  • Contact
Visit Vectencia Shop

Follow Me

Privacy Policy

2014 - 2026 © davthecoder is trading as Vectencia Ltd.

davthecoder
davthecoder.com
davthecoder × Vectencia
🖥️

Ktor Server Gotchas

Find the bugs in each code snippet

File Upload Handler1 P03 total
1/4
1fun Application.configureRouting() {
2 routing {
3 post("/upload") {
4 val multipart = call.receiveMultipart()
5 var fileName = ""
6
7 multipart.forEachPart { part ->
8 when (part) {
9 is PartData.FileItem -> {
10 fileName = part.originalFileName ?: "upload"
11 val file = File("/uploads/$fileName")
12 file.outputStream().use { output ->
13 part.streamProvider().copyTo(output)
14 }
15 }
16 else -> {}
17 }
18 part.dispose()
19 }
20
21 call.respondText("Uploaded: $fileName")
22 }
23 }
24}
Click on the lines you think have bugsFound 0 of 3
←→NavigateAShow remainingRReset
🎯Bug Formula: What's wrong → What breaks for the user → The fix → The trade-off