I want to upload image to the amazon S3 server ```...
# ktor
h
I want to upload image to the amazon S3 server
Copy code
<http://httpClient.post|httpClient.post><Unit> {
                val bucket = it.fields.bucket
                url {
                    encodedPath = bucket
                }
                body = MultiPartFormDataContent(
                    formData {
                        append("bucket", bucket)
                        append("Policy", it.fields.policy)
                        append("X-Amz-Date", it.fields.date)
                        append("X-Amz-Algorithm", it.fields.algorithm)
                        append("X-Amz-Signature", it.fields.signature)
                        append("X-Amz-Security-Token", it.fields.securityToken)
                        append("X-Amz-Credential", it.fields.credential)
                        append("acl", it.fields.acl)
                        append("key", it.fields.key)
                        appendInput(
                            key = "file",
                            headers = Headers.build {
                                append(HttpHeaders.ContentDisposition, "filename=uuid.jpg")
                                append(HttpHeaders.ContentType, "image/jpeg")
                            }) {
                                buildPacket { writeFully(input.imageByteArray) }
                            }
                    }
                )
            }
but I meet the below error
Copy code
javax.net.ssl.SSLException: Write error: ssl=0xcbc0b608: I/O error during system call, Broken pipe
😞 If I upload the image to another server (not S3 anymore), the upload is successfully anyone help me 😞 ?
t
Are X-Amz-Date and others supposed to be headers? It looks like you’re appending as form data in the body.
h
thx all, I replaced
appendInput
above by
append
and it worked