I am facing a very strange behaviour with a downlo...
# ktor
a
I am facing a very strange behaviour with a download button and a video. I am not sure how to debug this so any help is welcome. I have a page with a href and a video (see the routing setup below). If the anchor is the only tag in the page clicking on it, then the file starts downloading, no problem here. When I have both the anchor tag and the video tag, clicking on the anchor doesn’t trigger the download… I also noticed that it will eventually start downloading, only if I click on the video 🤯
Copy code
fun Application.configureRouting() {
    routing {
        static("/vid") {
            files("videos")
        }
        get("/download/*") {
            val file = File("./files/hello.txt")
            call.respondFile(file)
        }
        get("/") {
            call.respondHtml {
                body {
                    a(href = "/download/hello.txt") {
                        attributes["download"] = ""
                        +"Download"
                    }
                    video {
                        loop = true
                        controls = true
                        source {
                            src = "/vid/vid.mp4"
                            type = "video/mp4"
                        }
                    }
                }
            }
        }
    }
}
a
On my machine in the Chrome browser the file
hello.txt
can be downloaded without problems.
a
I did a few tests and I think the issue is the video file itself. I am generating the videos on the backend so maybe some ffmpeg flag is missing. It is weird though. I had no issue displaying the videos and having a download link on a php server