Get file path of uploaded file/files

Hello! I have the following issue: since I don’t want to store uploaded by user files in my database, I want to store them on a server, and in my database, I want to store only file path to the folder with these files on a server. How can I achieve this using vaadin`s upload component?

There is
https://vaadin.com/api/platform/14.3.3/com/vaadin/flow/component/upload/SucceededEvent.html
from where you can get the file name and the content.

It’s up to you to store the file somewhere and to save the path to the database.

There is by design no way getting the real path on the clients filesystem. You can only get the content and the name on the server side.

INPUTsys Chris Peter:
There is
https://vaadin.com/api/platform/14.3.3/com/vaadin/flow/component/upload/SucceededEvent.html
from where you can get the file name and the content.

It’s up to you to store the file somewhere and to save the path to the database.

There is by design no way getting the real path on the clients filesystem. You can only get the content and the name on the server side.

Thank you for your answer. I know that this is unreal to get the path on the cliens fylesystem, I don’t need it. My question is how to get the file path of the filesystem of server, where user uploads his files.

The uploaded file is not in the filesystem of the server. The content of the file is uploaded as a byte array, which is put into some kind of Memory Buffer. After the upload, you can read the bytes from that buffer.

It is then up to you to write the file in your filesystem. You have all the necessary information like filename, filetype, and content inside the SucceededEvent. Since it’s you who writes the file into the server filesystem, you should also know the path of that file which you can then write into your DB.

Kaspar Scherrer:
The uploaded file is not in the filesystem of the server. The content of the file is uploaded as a byte array, which is put into some kind of Memory Buffer. After the upload, you can read the bytes from that buffer.

It is then up to you to write the file in your filesystem. You have all the necessary information like filename, filetype, and content inside the SucceededEvent. Since it’s you who writes the file into the server filesystem, you should also know the path of that file which you can then write into your DB.

thank you very much for your reply, now I have a better understanding

To be exact: There are implementations for both FileBuffer and MemoryBuffer, so it may happen that the files are temporarily saved to the file system. But there is no guarantee that you can access them or get their paths.