diff options
author | Marvin Borner | 2019-04-21 18:34:48 +0200 |
---|---|---|
committer | Marvin Borner | 2019-04-21 18:34:48 +0200 |
commit | a5f26def08e100bf74e90d09298ad81e9224e249 (patch) | |
tree | 3dd897b3962c25204a7826d9de2c81e17a76ee5f /src/main/kotlin/FileController.kt | |
parent | 191e1976d93aaf0143f84fda86a4805d3b7cede8 (diff) |
Added download button
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/main/kotlin/FileController.kt')
-rw-r--r-- | src/main/kotlin/FileController.kt | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/kotlin/FileController.kt b/src/main/kotlin/FileController.kt index b7ff9d7..40ca1c9 100644 --- a/src/main/kotlin/FileController.kt +++ b/src/main/kotlin/FileController.kt @@ -22,6 +22,7 @@ class FileController { val firstParam = ctx.splat(0) ?: "" File(usersFileHome).mkdirs() when { + ctx.queryParam("raw") != null -> ctx.result(FileInputStream(File("$usersFileHome/$firstParam"))) File("$usersFileHome/$firstParam").isDirectory -> { val files = ArrayList<Array<String>>() Files.list(Paths.get("$usersFileHome/$firstParam/")).forEach { @@ -46,10 +47,8 @@ class FileController { files.sortWith(compareBy { it.first() }) ctx.render( "files.rocker.html", TemplateUtil.model( - "files", - files, - "path", - (if (firstParam.firstOrNull() == '/') firstParam.drop(1) else firstParam) + "files", files, + "path", (if (firstParam.firstOrNull() == '/') firstParam.drop(1) else firstParam) ) ) } @@ -227,7 +226,7 @@ class FileController { "files.rocker.html", TemplateUtil.model( "files", files, "path", - (if (sharedFileData.fileLocation.firstOrNull() != '/') "/${sharedFileData.fileLocation}" else sharedFileData.fileLocation) + (if (sharedFileData.fileLocation.firstOrNull() == '/') sharedFileData.fileLocation.drop(1) else sharedFileData.fileLocation) ) ) } |