Skip to content

Commit

Permalink
fixed deprecated provider and link in README
Browse files Browse the repository at this point in the history
  • Loading branch information
VGoncharova committed Nov 29, 2024
1 parent e2be7b2 commit 1d478b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion client-multipart/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Client Multipart

A sample project for [Ktor](https://ktor.io) showing how to send [multipart data](https://ktor.io/docs/request.html#upload_file) from the HttpClient.
A sample project for [Ktor](https://ktor.io) showing how to
send [multipart data](https://ktor.io/docs/client-requests.html#upload_file) from the HttpClient.

## Running

Expand Down
11 changes: 6 additions & 5 deletions client-multipart/src/MultipartApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.http.content.*
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.ktor.util.*
import io.ktor.utils.io.*
import io.ktor.utils.io.core.*
import io.ktor.utils.io.jvm.javaio.*

Check warning

Code scanning / detekt

Wildcard imports should be replaced with imports using fully qualified class names. Wildcard imports can lead to naming conflicts. A library update can introduce naming clashes with your classes which results in compilation errors. Warning

io.ktor.utils.io.jvm.javaio.* is a wildcard import. Replace it with fully qualified imports.
import kotlinx.io.readByteArray
import java.util.*

fun main() {
Expand Down Expand Up @@ -41,11 +41,11 @@ fun main() {
"FormItem(${part.name},${part.value})"
}
is PartData.FileItem -> {
val bytes = part.streamProvider().readBytes()
val bytes = part.provider().toInputStream().readAllBytes()
"FileItem(${part.name},${part.originalFileName},${hex(bytes)})"
}
is PartData.BinaryItem -> {
"BinaryItem(${part.name},${hex(part.provider().readBytes())})"
"BinaryItem(${part.name},${hex(part.provider().readByteArray())})"
}
else -> "Unknown"
}
Expand All @@ -59,7 +59,8 @@ fun main() {
}

class MultiPartContent(val parts: List<Part>) : OutgoingContent.WriteChannelContent() {
val uuid = UUID.randomUUID()
val uuid: UUID?
get() = UUID.randomUUID()
val boundary = "***ktor-$uuid-ktor-${System.currentTimeMillis()}***"

data class Part(
Expand Down

0 comments on commit 1d478b2

Please sign in to comment.