cuba-platform / yarg

Yet Another Report Generator - CUBA Platform reporting engine
https://www.cuba-platform.com
Apache License 2.0
239 stars 75 forks source link

Why is documentPath necessary in ReportTemplateBuilder when using InputStream? #89

Open ksdev-pl opened 5 years ago

ksdev-pl commented 5 years ago

Hi

If we are creating new ReportTemplateBuilder() using InputStream instead of a File, why is the documentPath necessary?

For example, here is the method to create new ReportTemplateBuilder using InputStream:

ClassPathResource resource = ...

InputStream fileStream = resource.getInputStream();

ReportTemplateBuilder reportTemplateBuilder = new ReportTemplateBuilder()
            .documentPath("")
            .documentName("document.docx")
            .documentContent(fileStream)
            .outputType(ReportOutputType.docx);

As you can see, I'm using an empty string as the documentPath, because an exception is thrown without it.

I'm using an InputStream instead of a File, because the file is inside a jar (generated by spring boot) and I don't wish to create unnecessary temporary files.

Maybe it's by design and an empty string is a correct solution of this problem?