Код: Выделить всё
curl -X 'POST' \
'https://example.com/rest/someservice?oauth_token=' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@docs_recognize_ok.jpg;type=image/jpeg' \
-F 'meta={
"images": [
{
"name": "file"
}
]
}'
На данный момент я пытаюсь справиться с этим как :
Код: Выделить всё
val json = "{\n" +
" \"images\": [\n" +
" {\n" +
" \"name\": \"file\"\n" +
" }\n" +
" ]\n" +
"}"
val filesList = mutableListOf
()
val partData = formData {
append(key = "meta", value = json, headers = Headers.build {
append(HttpHeaders.ContentType, "application/json; charset=utf-8")
})
request.images.forEach { file ->
append(
"file",
InputProvider { File(file.imageFileName).inputStream().asInput() },
Headers.build {
append(HttpHeaders.ContentType, "image/jpeg")
}
)
}
}
filesList.addAll(partData)
httpClient.post("rest/someservice") {
setBody(MultiPartFormDataContent(parts = filesList))
parameters {
append("oauth_token", apiKey)
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... rl-example
Мобильная версия