Skip to content

Instantly share code, notes, and snippets.

@hoangnt-2197
Created October 22, 2020 14:28
Show Gist options
  • Save hoangnt-2197/c816e0504a502bb213e287a8418fdacd to your computer and use it in GitHub Desktop.
Save hoangnt-2197/c816e0504a502bb213e287a8418fdacd to your computer and use it in GitHub Desktop.
...
@Configuration
@EnableConfigurationProperties(KnoteProperties.class)
class KnoteConfig implements WebMvcConfigurer {
@Autowired
private KnoteProperties properties;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/uploads/**")
.addResourceLocations("file:" + properties.getUploadDir())
.setCachePeriod(3600)
.resourceChain(true)
.addResolver(new PathResourceResolver());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment