Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed deprecated provider and link in README #205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.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 @@
"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 @@
}

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
Loading