2

I want to use resources from static directory and this directory may have another subdirectories.

In spring boot application.properties file I am using below key to refer outside directory:C:/custResources/. I am able to refer resources from this directory but not from the subdirectoriese e.g. C:/custResources/1, C:/custResources/2 etc.

spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:/C:/custResources/

Harshal Patil
  • 349
  • 1
  • 7
  • 26
  • 1
    Do you overwrite the property `spring.mvc.static-path-pattern`? – Steffen Harbich May 30 '18 at 12:13
  • 1
    Is sub directory working for one of the classpath paths (e.g. when you put something in `classpath:/static/1/`)? – Steffen Harbich May 30 '18 at 12:19
  • Once you have the base location, you can with Java create whatever you want: https://stackoverflow.com/questions/28947250/create-a-directory-if-it-does-not-exist-and-then-create-the-files-in-that-direct – Adam May 30 '18 at 16:42
  • Why do you want to place these resources outside of your project? – Paul Warren Jun 01 '18 at 04:06
  • There are some training videos in application to which I have to give access using href and play it in html. Is it correct way to do so? – Harshal Patil Jun 01 '18 at 07:45

1 Answers1

0

Looks like I am doing something wrong.

Below property is sufficient to add the whole directory and its folder as static location. spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:/C:/resources

I am able to access video placed inside C:/resources/1 as localhost:8080/1/sample.mp4 and so on.

Harshal Patil
  • 349
  • 1
  • 7
  • 26