mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-23 16:05:09 +00:00
Update src/test/java/SpyPDFDocumentFactory.java
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
9a006a35bd
commit
0af295639d
@ -1,30 +1 @@
|
|||||||
import org.apache.pdfbox.io.RandomAccessStreamCache.StreamCacheCreateFunction;
|
// This file has been removed because SpyPDFDocumentFactory is already implemented in stirling/software/SPDF/service.
|
||||||
|
|
||||||
import stirling.software.SPDF.service.CustomPDFDocumentFactory;
|
|
||||||
import stirling.software.SPDF.service.PdfMetadataService;
|
|
||||||
|
|
||||||
class SpyPDFDocumentFactory extends CustomPDFDocumentFactory {
|
|
||||||
enum StrategyType {
|
|
||||||
MEMORY_ONLY, MIXED, TEMP_FILE
|
|
||||||
}
|
|
||||||
|
|
||||||
public StrategyType lastStrategyUsed;
|
|
||||||
|
|
||||||
public SpyPDFDocumentFactory(PdfMetadataService service) {
|
|
||||||
super(service);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StreamCacheCreateFunction getStreamCacheFunction(long contentSize) {
|
|
||||||
StrategyType type;
|
|
||||||
if (contentSize < 10 * 1024 * 1024) {
|
|
||||||
type = StrategyType.MEMORY_ONLY;
|
|
||||||
} else if (contentSize < 50 * 1024 * 1024) {
|
|
||||||
type = StrategyType.MIXED;
|
|
||||||
} else {
|
|
||||||
type = StrategyType.TEMP_FILE;
|
|
||||||
}
|
|
||||||
this.lastStrategyUsed = type;
|
|
||||||
return super.getStreamCacheFunction(contentSize); // delegate to real behavior
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user