Anyone has come across this issue where the uploaded filename is looking a bit weird.
I am trying this Vaadin Plupload addon which is a very nice addon. However, it uploads the wrong file name.
//add file uploaded handler
uploader.addFileUploadedListener(new Plupload.FileUploadedListener() {
@Override
public void onFileUploaded(PluploadFile file) {
File uploadedFile = file.getUploadedFile();
System.out.println("This file was just uploaded: "
+ uploadedFile.getAbsolutePath());
}
});
And it gives me this kind of file name o_199r9ll9e1g6q15vmrdj13l51rdbl .txt ...how do I get the normal.txt file name instead of such weird file name.
Finally solved this issue, here is the discussion for this specific issue from Vaadin site:
Path myPath = Paths.get(YOUR_UPLOAD_DIRECTORY + file.getId() + (FilenameUtils.getExtension(file.getName()).isEmpty()
? "" : ('.' + FilenameUtils.getExtension(file.getName()))));
Path rF = Paths.get(YOUR_UPLOAD_DIRECTORY + file.getName());
try {
Files.move(myPath, rF, StandardCopyOption.REPLACE_EXISTING);
//refresh your tree table container
} catch (IOException e) {
log.error("Unable to rename file" + file.getName(), e);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.