[
https://issues.apache.org/jira/browse/TIKA-2849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16822048#comment-16822048
]
Tim Allison commented on TIKA-2849:
-----------------------------------
It's tricky because we want to put the open package back on the parent
TikaInputStream if there is success.
How about adding a {{public Path getPath(int maxBytes) throws IOException}} to
TikaInputStream? This would return null or (throw an IOException?) if it
didn't copy the full stream?
{noformat}
public Path getPath(int maxBytes) throws IOException {
if (path == null) {
if (position > 0) {
throw new IOException("Stream is already being read");
} else {
path = tmp.createTempFile();
if (maxBytes > -1) {
try (InputStream lookAhead = new LookaheadInputStream(in,
maxBytes)) {
Files.copy(lookAhead, path, REPLACE_EXISTING);
if (Files.size(path) >= maxBytes) {
return null;
}
}
} else {
// Spool the entire stream into a temporary file
Files.copy(in, path, REPLACE_EXISTING);
}
{noformat}
> TikaInputStream copies the input stream locally
> -----------------------------------------------
>
> Key: TIKA-2849
> URL: https://issues.apache.org/jira/browse/TIKA-2849
> Project: Tika
> Issue Type: Bug
> Affects Versions: 1.20
> Reporter: Boris Petrov
> Assignee: Tim Allison
> Priority: Major
>
> When doing "tika.detect(stream, name)" and the stream is a "TikaInputStream",
> execution gets to "TikaInputStream#getPath" which does a "Files.copy(in,
> path, REPLACE_EXISTING);" which is very, very bad. This input stream could
> be, as in our case, an input stream from a network file which is tens or
> hundreds of gigabytes large. Copying it locally is a huge waste of resources
> to say the least. Why does it do that and can I make it not do it? Or is this
> something that has to be fixed in Tika?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)