Part

annotation class Part(val value: String = KTORGEN_DEFAULT_NAME, val encoding: String = "binary")(source)

Annotate a single part of a multipart request.

Where the name of the parameter is used as the name of the part (or the value if set), the value of the parameter is used as the body of the part.

If the type is PartData the value will be used directly with its content type.

@POST("upload")
@Multipart
suspend fun uploadFile(
@Part(value = "other_name") description: String,
@Part data: List<PartData>,
): String

// Generated code
val _content = formData {
this.append(key = """other_name""", value = """$description""")
}
this.setBody(MultiPartFormDataContent(listOf(data) + _content))

See also

Properties

Link copied to clipboard

The Content-Transfer-Encoding of this part.

Link copied to clipboard

The name of the part. Default the name of the function parameter