Hello, I want to create a service that accepts base64 ppt/pptx and will add a picture (png) there at the end and convert to pdf and send the base64 created pdf. I use LibreOffice and XMLSlideShow.
Problems:
- When I create a file from base64 ppt/pptx, but an error occurs when opening it
the code itself is like this
byte[] bytes = Base64.getDecoder().decode(base64);
if (bytes != null) {
try {
FileDescriptor fileDescriptor = dataManager.create(FileDescriptor.class);
fileDescriptor.setName(name + "." + type);
fileDescriptor.setCreateDate(new Date());
fileDescriptor.setExtension(type);
fileLoader.saveStream(fileDescriptor, () -> new ByteArrayInputStream(bytes));
// сохраняем и присваиваем FileDescriptor
fileDescriptor = dataManager.commit(fileDescriptor);
NewEntity newEntity = metadata.create(NewEntity.class);
newEntity.setFile(fileDescriptor);
dataManager.commit(newEntity);
} catch (FileStorageException e) {
throw new RuntimeException(e);
}
}
- XMLSlideShow works with FileInputStream and filePath is needed for this. How can I get the filePath of the created pptx file?
the sample code that I wrote (does not work)
FileInputStream inputStream = new FileInputStream("http://localhost:8080/app/rest/v2/files/" + document.toUrlParam());
XMLSlideShow hslfSlideShow = new XMLSlideShow (inputStream);
document is a created FileDescriptor