mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-09 15:07:58 +08:00
[+] Serve uploads directory
This commit is contained in:
@@ -4,6 +4,8 @@ import ext.path
|
|||||||
import jakarta.annotation.PostConstruct
|
import jakarta.annotation.PostConstruct
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = "paths")
|
@ConfigurationProperties(prefix = "paths")
|
||||||
@@ -18,4 +20,17 @@ class PathProps {
|
|||||||
mai2Portrait = mai2Portrait.path().apply { toFile().mkdirs() }.toString()
|
mai2Portrait = mai2Portrait.path().apply { toFile().mkdirs() }.toString()
|
||||||
aquaNetPortrait = aquaNetPortrait.path().apply { toFile().mkdirs() }.toString()
|
aquaNetPortrait = aquaNetPortrait.path().apply { toFile().mkdirs() }.toString()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class UploadStatic(val paths: PathProps): WebMvcConfigurer {
|
||||||
|
override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
|
||||||
|
mapOf(
|
||||||
|
"/uploads/net/portrait/**" to paths.aquaNetPortrait,
|
||||||
|
"/uploads/mai2/portrait/**" to paths.mai2Portrait,
|
||||||
|
"/uploads/mai2/plays/**" to paths.mai2Plays
|
||||||
|
).forEach { (k, v) ->
|
||||||
|
registry.addResourceHandler(k).addResourceLocations("file:$v").setCachePeriod(10).resourceChain(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user