79742240

Date: 2025-08-21 11:59:16
Score: 0.5
Natty:
Report link

I turned out that I mixed multipart/form-data and application/octet-stream approaches.

The correct Kotlin code for Ktor-client to upload to Cloudflare R2 will be:

   suspend fun uploadS3File2(
        url: String,
        file: File
    ) = client.put(url) {
        setBody(file.readChannel())
        headers {
            append(HttpHeaders.ContentType, ContentType.Application.OctetStream)
            append(HttpHeaders.ContentLength, "${file.length()}")
        }
    }
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: cora32