Dear team,
My screen have a file upload field. I need get local path of file after customer upload into web.
Can you help me about this. Thanks!
You can obtain just uploaded into temporary storage file via FileUploadingAPI:
@Inject
private FileUploadField uploadField;
@Inject
private FileUploadingAPI fileUploadingAPI;
@Override
public void init(Map<String, Object> params) {
uploadField.addFileUploadSucceedListener(event -> {
File file = fileUploadingAPI.getFile(uploadField.getFileId());
if (file != null)
showNotification("Uploaded file in temporary storage: " + file, NotificationType.HUMANIZED);
else
showNotification("Cannot find file in temporary storage", NotificationType.HUMANIZED);
});
}
Dear Konstantin Krivopustov,
if i have alreay saved the file in db. After that, i get file from db and i have a file descriptor. And how i get local file of this fd object.
Thanks for responding
You cannot get java.util.File object for a file in the file storage. You can only read this file via InputStream using for example the FileLoader interface.
ok i will save uploaded file into my table in uploadField.addFileUploadSucceedListener and load file from that table. Thanks for your responding!