Hello,
I'm trying to download an auto generated json content. The only way it works is with respondBytes, but you can't specify the name of the file, it's always the route name. I wan't to specify the name depending the user and the extension.
This is what I'm using, where json is the content to download.
call.respondBytes(json, ContentType.Application.OctetStream)
Thanks.
I guess you have to use the Content-Disposition header:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
// Untyped:
call.response.header(HttpHeaders.ContentDisposition, "attachment; filename=\"myfilename.bin\"")
// Typed:
call.response.header(HttpHeaders.ContentDisposition, ContentDisposition.Attachment.withParameter(ContentDisposition.Parameters.FileName, "myfile.bin").toString())
I have updated the documentation to reflect this: http://ktor.io/servers/calls/responses.html#content-disposition
Thanks. Resolved.
Most helpful comment
I guess you have to use the
Content-Dispositionheader:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
I have updated the documentation to reflect this: http://ktor.io/servers/calls/responses.html#content-disposition