bitkid
10/08/2019, 10:32 AMfor (line in part.streamProvider().reader().readLines())
it fails with "Underlying input stream returned zero bytes" but when i do for (line in ByteArrayInputStream(part.streamProvider().readAllBytes()).reader().readLines())
it works as expected. the weird part is when i run "unix2dos file" before uploading it, it works also with the first bit of code. do i need some content type headers or something like this? reading the file locally also works with the first part, so something along the lines for(line in File("bla").reader().readLines())
bitkid
10/08/2019, 10:33 AMbitkid
10/08/2019, 10:33 AMprotected fun TestApplicationEngine.uploadDataForMatrix(file: File, path: String, method: HttpMethod = HttpMethod.Put): TestApplicationResponse {
return handleRequest(method, path) {
val boundary = "***bbb***"
addHeader(HttpHeaders.ContentType, ContentType.MultiPart.FormData.withParameter("boundary", boundary).toString())
setBody(boundary, listOf(
PartData.FileItem({ file.inputStream().asInput() }, {}, headersOf(
HttpHeaders.ContentDisposition,
ContentDisposition.File
.withParameter(ContentDisposition.Parameters.Name, "file")
.withParameter(ContentDisposition.Parameters.FileName, "file.txt")
.withParameter(ContentDisposition.Parameters.Size, "${file.length()}")
.toString()
))
))
}.response
}
bitkid
10/08/2019, 10:52 AMbitkid
10/08/2019, 11:36 AMbitkid
10/08/2019, 11:40 AM