Skip to content

Instantly share code, notes, and snippets.

@bitkid
Created January 21, 2020 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitkid/e49c12c63cc4277a6139d3992a16ecb8 to your computer and use it in GitHub Desktop.
Save bitkid/e49c12c63cc4277a6139d3992a16ecb8 to your computer and use it in GitHub Desktop.
file.inputStream().buffered().use {
httpClient.submitFormWithBinaryData<HttpResponse>(fullUrl, formData {
appendInput("file", headersOf(HttpHeaders.ContentDisposition,
ContentDisposition.File
.withParameter(ContentDisposition.Parameters.Name, file.name)
.withParameter(ContentDisposition.Parameters.FileName, file.file.name)
.toString())) {
it.asInput()
}
}).also {
logger.info { "importing file ${file.name} (${it.status})" }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment