1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.web.WebInterface
4 import net.pterodactylus.sone.web.page.FreenetPage
5 import net.pterodactylus.sone.web.page.FreenetRequest
6 import net.pterodactylus.util.web.Response
10 * Page that delivers a {@link TemporaryImage} to the browser.
12 class GetImagePage(webInterface: WebInterface): FreenetPage {
14 private val core = webInterface.core
16 override fun getPath(): String {
17 return "getImage.html"
20 override fun isPrefixPage(): Boolean {
24 override fun handleRequest(request: FreenetRequest, response: Response): Response {
25 val image = core.getTemporaryImage(request.httpRequest.getParam("image")) ?: return response.apply {
27 statusText = "Not found."
28 contentType = "text/html; charset=utf-8"
30 return response.apply {
32 contentType = image.mimeType
33 content.write(image.imageData)
34 addHeader("Content-Disposition", "attachment; filename=${image.id}.${image.mimeType.split('/')[1]}")
38 override fun isLinkExcepted(link: URI?): Boolean {