Use Ktor's Content-Disposition builder

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent 412d6f4c1f
commit 5cfb234cc7
  1. 10
      archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt

@ -1,7 +1,9 @@
package org.openrs2.archive.web package org.openrs2.archive.web
import io.ktor.application.ApplicationCall import io.ktor.application.ApplicationCall
import io.ktor.http.ContentDisposition
import io.ktor.http.ContentType import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpStatusCode import io.ktor.http.HttpStatusCode
import io.ktor.response.header import io.ktor.response.header
import io.ktor.response.respond import io.ktor.response.respond
@ -31,7 +33,13 @@ public class CachesController @Inject constructor(
return return
} }
call.response.header("Content-Disposition", "attachment; filename=\"cache.zip\"") call.response.header(
HttpHeaders.ContentDisposition,
ContentDisposition.Attachment
.withParameter(ContentDisposition.Parameters.FileName, "cache.zip")
.toString()
)
call.respondOutputStream(contentType = ContentType.Application.Zip) { call.respondOutputStream(contentType = ContentType.Application.Zip) {
DiskStoreZipWriter(ZipOutputStream(this), alloc = alloc).use { store -> DiskStoreZipWriter(ZipOutputStream(this), alloc = alloc).use { store ->
exporter.export(id, store) exporter.export(id, store)

Loading…
Cancel
Save