I’m trying to implement a full file manager using the Upload component to allow users to upload files to the server.
I have the FilesystemDataProvider working except for one issue.
When I upload a new file, I call FilesystemDataProvider.refreshAll().
The treegrid redraws all of the items but it doesn’t show the newly uploaded file.
I’ve check and the file exists before the I call refreshAll().
If I hit F5 to refresh the browser page the file then appears.
upload.addSucceededListener(event ->
{
fileSystem.refreshAll();
});
File rootFile = new File(FileStore.instance().managedStorePath);
FilesystemData root = new FilesystemData(rootFile, false);
fileSystem = new FilesystemDataProvider(root);
tree = new TreeGrid<>();
tree.setDataProvider(fileSystem);
tree.addHierarchyColumn(file -> file.getName()).setHeader("Name").setAutoWidth(true).setResizable(true);
tree.addColumn(file -> file.length()).setHeader("Size");
tree.addColumn(file -> file.isDirectory() ? "Directory" : "File").setHeader("Type");
tree.addComponentColumn(file -> buildDelete(file)).setHeader("Size");