I
I
IvanN7772020-10-16 15:56:38
Java
IvanN777, 2020-10-16 15:56:38

How to upload files to have access to them later?

In WebMvcConfig

registry.addResourceHandler("/resources/**")
                .addResourceLocations("/public", "classpath:/static/");


I just upload files to
private static final String STATIC_PATH = "src/main/resources/static";


I'm running in Intelij. The files are downloaded to the specified directory, but they become available only after preloading and possibly clean.
And how to make the files available on the fly, uploaded and already available.
Or is it because of ide.
So far I’m just learning, I didn’t find it about downloading by Google.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan, 2020-10-16
@IvanN777

Hello!
You upload files to the resources directory, but to make them available you need to recompile the project again. Usually, if some kind of file loading logic is implied in the application, then the files are loaded into another directory outside the project. For example, /home/example.com/uploads A path to a file, etc. be stored in the database. If necessary, you can access the database and get the path to the file with the name and give it to the client. If this is about...

M
mystifier, 2020-10-16
@mystifier

How exactly are the files inaccessible?
To access files in resources I usually use:
String localName = context.getRealPath("/resources/") + "some file name";
context is
@Autowired
ServletContext context;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question