Widget to get a file path, not uploading it

Hi, greetings from Argentina! :slight_smile:

Since I’ve readed about Vaadin, I’m falling in love with it!
Right now, I’m facing an “akward” problem.

As I’m using a vaadin app as “front end” to access the model in a neodatis db, i need to get the neodatis file path, not its contents (beacuse the user can changed them updating the DB contents).

So, I need something like the upload component, but instead of getting the selected file contents as a resource, I need the selected file absolute path.

Is there anithing in vaadin which can be used in this scope?

I looked over FileSystemContainer, but it doesn’t look as the right answer :frowning:

Would be rigth to use a FileResource (the one used for downloading) forcing some kind of exception with the selected path in it? I don’t see it as a correct solution, but it could serve me as a temporal solution if nothing exists! :slight_smile:



I’m not totally sure of what you’re trying to achieve… The upload ‘browse’ -dialog shows files on the computer where the browser is running, but the server can not access these files unless you upload them. And the browser can not access files on the server… Unless you’re running the server and the browser on the same machine?

If the neodatis file is indeed in a place so that the server can access it, using the FileSystemContainer might actually be the correct solution in your case. By using it as a data source for Tree, you can allow the user to browse for the file.

Best Regards,

I’m trying to build a Swing-like file chooser using the Tree component and the FilesystemContainer. Works as expected, with one hitch:

When a file or directory is selected, I want to get its complete path. Nowhere, it seems, is that obtainable from either FilesystemContainer or FilesystemContainer.FileItem. It’s easy to get the name of the file (see FilesystemContainer.FileItem.getName() or even FilesystemContainer.FileItem.toString() ). The wrapped java.io.File object is not exposed so you can’t access that.

Also, FilesystemContainer uses the wrapped File object as the “itemId”, so you are unable to use its “getChildren(Object itemId)” or “getParent(Object itemId)”.

Am I missing something?

It should not. The itemId should be of type java.io.File.

I have the same need: browse for a file on local computer and then put the full file path into TextField, NOT upload it.
my Vaadin application runs on a local machine (not on a server) so “uploading” does not make sense here, I just need a simple way for a user to find the required file on his disk.

have you found a solution?

Not quite certain, but I believe browser security restrictions prevent you from doing this with the browser file selection dialog. To circumvent these, you would need a native browser plug-in handling the browsing and getting the data.
Your application probably needs to implement the browsing functionality itself, using the server file system (which happens to be the same as the client in your case).