Hi, In Cuba there was something like FileDescriptor to upload or download files. In Jmix I can’t find it… what is the best way to upload for example pdf file to database and then download it by clicking specified button? In Component Pallete is something like FileUploadField and it worked for .jpg image but does it also work for other file extensions?
What is my goal: Saving specified user’s documents to a list (
If it remains unclear after reading the docs, please let us know. We will be happy to clarify unclear moments (and also will know what to improve in the docs).
As DEFAULT_FORMATS is unmodifiableList I couldn’t add new DownloadFormat. I created a new method by using new List. It works same way but with option to add custom DownloadFormat’s.
public DownloadFormat getFormatByExtension(String extension) {
DownloadFormat pptx = new DownloadFormat("pptx-mime-type", "pptx");
if (StringUtils.isEmpty(extension)) {
return OCTET_STREAM;
}
String extLowerCase = StringUtils.lowerCase(extension);
List<DownloadFormat> formats = DEFAULT_FORMATS;
List<DownloadFormat> formatList = new ArrayList<>(formats);
formatList.add(pptx);
for (DownloadFormat f : formatList) {
if (f.getFileExt().equals(extLowerCase))
return f;
}
return OCTET_STREAM;
}