diff options
Diffstat (limited to 'src/main/java/com/juick/server/configuration')
-rw-r--r-- | src/main/java/com/juick/server/configuration/WwwAppConfiguration.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java b/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java index 534154af..2286165d 100644 --- a/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java +++ b/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java @@ -43,6 +43,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.resource.VersionResourceResolver; import javax.inject.Inject; +import java.net.MalformedURLException; +import java.nio.file.Paths; import java.util.Collections; import java.util.concurrent.TimeUnit; @@ -56,7 +58,7 @@ public class WwwAppConfiguration implements WebMvcConfigurer { private UserService userService; @Inject private TagService tagService; - @Value("${avatars_path:#{systemEnvironment['TEMP'] ?: 'file:/tmp/'}}") + @Value("${avatars_path:#{systemEnvironment['TEMP'] ?: '/tmp'}}") private String avatarsPath; @Bean public CaffeineCacheManager cacheManager() { @@ -126,11 +128,15 @@ public class WwwAppConfiguration implements WebMvcConfigurer { } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry - .addResourceHandler("/**", "/i/a/**") - .addResourceLocations("classpath:/static/", avatarsPath) - .setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS)) - .resourceChain(false) - .addResolver(new VersionResourceResolver().addContentVersionStrategy("/**", "/i/a/**")); + try { + registry + .addResourceHandler("/**", "/i/a/**") + .addResourceLocations("classpath:/static/", Paths.get(avatarsPath, "/a/").toUri().toURL().toString()) + .setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS)) + .resourceChain(false) + .addResolver(new VersionResourceResolver().addContentVersionStrategy("/**", "/i/a/**")); + } catch (MalformedURLException e) { + e.printStackTrace(); + } } } |