return (size > 2097152) || (!mimeType.startsWith("image/") && !mimeType.startsWith("text/html"))
}
- override fun loaded(uri: FreenetURI, mimeType: String, data: ByteArray) {
- MimeType(mimeType).also { mimeType ->
+ override fun loaded(uri: FreenetURI, mimeTypeText: String, data: ByteArray) {
+ MimeType(mimeTypeText).also { mimeType ->
when {
mimeType.primaryType == "image" -> {
ByteArrayInputStream(data).use {
ImageIO.read(it)
}?.let {
elementCache.get(uri.toString().decode().normalize()) {
- LinkedElement(uri.toString(), properties = mapOf("size" to data.size, "sizeHuman" to data.size.human))
+ LinkedElement(uri.toString(), properties = mapOf("type" to "image", "size" to data.size, "sizeHuman" to data.size.human))
}
}
}
val document = Jsoup.parse(data.toString(Charset.forName(mimeType.getParameter("charset") ?: "UTF-8")))
elementCache.get(uri.toString().decode().normalize()) {
LinkedElement(uri.toString(), properties = mapOf(
- "size" to data.size, "sizeHuman" to data.size.human,
+ "type" to "html", "size" to data.size, "sizeHuman" to data.size.human,
"title" to document.title().emptyToNull,
"description" to (document.metaDescription ?: document.firstNonHeadingParagraph)
))