I saved my docx documents temporarily as blob in a postgresql database using jdbc. After fetching and initializing them with help of the Document::constructor (Aspose 19.10) all of the created documents are blank.
Example code
List<Document> test(List<InputStream> streams) {
List<Document> a = new LinkedList<>();
for(InputStream stream: streams) {
a.add(new Document(stream);
}
return a;
}
The cause
The Document::constructor for inputstreams calls zz51.zzY(stream) and this method contains the following lines:
if (var0 instanceof FileInputStream) {
return new zz1K((FileInputStream)var0);
}
if (var0.markSupported()) {
return new zz1J(var0);
}
return zzX(var0);
My InputStream isn't of type FileInputStream but it supports marks and in my case it jumps into zz1J. The following snipped is the cause of my blank documents:
According the official javadoc its not recommended to do that (Javadoc InputStream) because "some implementations of InputStream will return the total number of bytes in the stream, many will not". So doesn't the BlobInputStream of the Postgresql-jdbc implementation which returns the default value of InputStream::available (Postgresql BlobInputStream).
Solution/Workaround
My workaround is to wrap the InputStream into a class that extands from InputStream and override the methods returning false in the method markSupported to skip the jump into zz1J. Instead it reads the stream as it is in zzX.
@i7i5 The issue you have reported earlier is fixed. The fix is included into the latest 20.01 release of Aspose.Words for Java. You can download this version from here.
I saved my docx documents temporarily as blob in a postgresql database using jdbc. After fetching and initializing them with help of the Document::constructor (Aspose 19.10) all of the created documents are blank.
Example code
The cause
The Document::constructor for inputstreams calls
zz51.zzY(stream)
and this method contains the following lines:My InputStream isn't of type FileInputStream but it supports marks and in my case it jumps into zz1J. The following snipped is the cause of my blank documents:
According the official javadoc its not recommended to do that (Javadoc InputStream) because "some implementations of InputStream will return the total number of bytes in the stream, many will not". So doesn't the BlobInputStream of the Postgresql-jdbc implementation which returns the default value of InputStream::available (Postgresql BlobInputStream).
Solution/Workaround
My workaround is to wrap the InputStream into a class that extands from InputStream and override the methods returning false in the method
markSupported
to skip the jump into zz1J. Instead it reads the stream as it is in zzX.br