Add public icon list endpoint
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.android.trisolarisserver.controller
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/icons")
|
||||
class IconFiles(
|
||||
@Value("\${storage.icons.png.root:/home/androidlover5842/docs/icons/png}")
|
||||
private val pngRoot: String
|
||||
) {
|
||||
|
||||
@GetMapping("/png")
|
||||
fun listPng(): List<String> {
|
||||
val dir = Paths.get(pngRoot)
|
||||
if (!Files.exists(dir) || !Files.isDirectory(dir)) {
|
||||
return emptyList()
|
||||
}
|
||||
Files.newDirectoryStream(dir).use { stream ->
|
||||
return stream
|
||||
.filter { Files.isRegularFile(it) }
|
||||
.map { it.fileName.toString() }
|
||||
.filter { it.lowercase().endsWith(".png") }
|
||||
.sorted()
|
||||
.toList()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user