This is an automated email from the ASF dual-hosted git repository. ndipiazza pushed a commit to branch TIKA-4243-tika-config-overhaul-parsecontext in repository https://gitbox.apache.org/repos/asf/tika.git
commit 4afd23c82becb3f1874104f6b82c59caa68561ad Author: Nicholas DiPiazza <[email protected]> AuthorDate: Sun May 26 10:49:53 2024 -0500 TIKA-4252: switch to using the parse context for additional http headers --- .../apache/tika/pipes/fetcher/EmptyFetcher.java | 3 +- .../org/apache/tika/pipes/fetcher/Fetcher.java | 7 +++- .../apache/tika/pipes/fetcher/RangeFetcher.java | 8 +++- .../tika/pipes/fetcher/fs/FileSystemFetcher.java | 4 +- .../apache/tika/pipes/fetcher/url/UrlFetcher.java | 3 +- .../org/apache/tika/pipes/async/MockFetcher.java | 3 +- .../org/apache/tika/pipes/fetcher/MockFetcher.java | 3 +- .../tika/pipes/fetcher/azblob/AZBlobFetcher.java | 3 +- .../apache/tika/pipes/fetcher/gcs/GCSFetcher.java | 3 +- tika-pipes/tika-fetchers/tika-fetcher-http/pom.xml | 6 ++- .../tika/pipes/fetcher/http/HttpFetcher.java | 19 +++++++-- .../fetcher/http/config/AdditionalHttpHeaders.java | 49 ++++++++++++++++++++++ .../tika/pipes/fetcher/http/HttpFetcherTest.java | 48 +++++++++++++++++++++ .../http/config/AdditionalHttpHeadersTest.java | 24 +++++++++++ .../apache/tika/pipes/fetcher/s3/S3Fetcher.java | 5 ++- 15 files changed, 172 insertions(+), 16 deletions(-) diff --git a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/EmptyFetcher.java b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/EmptyFetcher.java index 022d00a8c..d64f81524 100644 --- a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/EmptyFetcher.java +++ b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/EmptyFetcher.java @@ -21,6 +21,7 @@ import java.io.InputStream; import org.apache.tika.exception.TikaException; import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; public class EmptyFetcher implements Fetcher { @@ -30,7 +31,7 @@ public class EmptyFetcher implements Fetcher { } @Override - public InputStream fetch(String fetchKey, Metadata metadata) throws TikaException, IOException { + public InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws TikaException, IOException { return null; } } diff --git a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/Fetcher.java b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/Fetcher.java index 1b3fa2a24..34d4297d5 100644 --- a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/Fetcher.java +++ b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/Fetcher.java @@ -21,6 +21,7 @@ import java.io.InputStream; import org.apache.tika.exception.TikaException; import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; /** * Interface for an object that will fetch an InputStream given @@ -33,5 +34,9 @@ public interface Fetcher { String getName(); - InputStream fetch(String fetchKey, Metadata metadata) throws TikaException, IOException; + default InputStream fetch(String fetchKey, Metadata metadata) throws TikaException, IOException { + return fetch(fetchKey, metadata, new ParseContext()); + } + + InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws TikaException, IOException; } diff --git a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/RangeFetcher.java b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/RangeFetcher.java index 0a3ceae7f..246165c98 100644 --- a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/RangeFetcher.java +++ b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/RangeFetcher.java @@ -21,6 +21,7 @@ import java.io.InputStream; import org.apache.tika.exception.TikaException; import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; /** * This class extracts a range of bytes from a given fetch key. @@ -28,7 +29,12 @@ import org.apache.tika.metadata.Metadata; public interface RangeFetcher extends Fetcher { //At some point, Tika 3.x?, we may want to add optional ranges to the fetchKey? - InputStream fetch(String fetchKey, long startOffset, long endOffset, Metadata metadata) + default InputStream fetch(String fetchKey, long startOffset, long endOffset, Metadata metadata) + throws TikaException, IOException { + return fetch(fetchKey, startOffset, endOffset, metadata, new ParseContext()); + } + + InputStream fetch(String fetchKey, long startOffset, long endOffset, Metadata metadata, ParseContext parseContext) throws TikaException, IOException; } diff --git a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/fs/FileSystemFetcher.java b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/fs/FileSystemFetcher.java index d926e3ca6..f3beae9d5 100644 --- a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/fs/FileSystemFetcher.java +++ b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/fs/FileSystemFetcher.java @@ -41,6 +41,7 @@ import org.apache.tika.metadata.FileSystem; import org.apache.tika.metadata.Metadata; import org.apache.tika.metadata.Property; import org.apache.tika.metadata.TikaCoreProperties; +import org.apache.tika.parser.ParseContext; import org.apache.tika.pipes.fetcher.AbstractFetcher; public class FileSystemFetcher extends AbstractFetcher implements Initializable { @@ -58,8 +59,7 @@ public class FileSystemFetcher extends AbstractFetcher implements Initializable } @Override - public InputStream fetch(String fetchKey, Metadata metadata) throws IOException, TikaException { - + public InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws IOException, TikaException { if (fetchKey.contains("\u0000")) { throw new IllegalArgumentException("Path must not contain \u0000. " + "Please review the life decisions that led you to requesting " + diff --git a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/url/UrlFetcher.java b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/url/UrlFetcher.java index f415a3560..7692516cd 100644 --- a/tika-core/src/main/java/org/apache/tika/pipes/fetcher/url/UrlFetcher.java +++ b/tika-core/src/main/java/org/apache/tika/pipes/fetcher/url/UrlFetcher.java @@ -24,6 +24,7 @@ import java.util.Locale; import org.apache.tika.exception.TikaException; import org.apache.tika.io.TikaInputStream; import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; import org.apache.tika.pipes.fetcher.AbstractFetcher; /** @@ -35,7 +36,7 @@ import org.apache.tika.pipes.fetcher.AbstractFetcher; public class UrlFetcher extends AbstractFetcher { @Override - public InputStream fetch(String fetchKey, Metadata metadata) throws IOException, TikaException { + public InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws IOException, TikaException { if (fetchKey.contains("\u0000")) { throw new IllegalArgumentException("URL must not contain \u0000. " + "Please review the life decisions that led you to requesting " + diff --git a/tika-core/src/test/java/org/apache/tika/pipes/async/MockFetcher.java b/tika-core/src/test/java/org/apache/tika/pipes/async/MockFetcher.java index 10af275e3..acb533ece 100644 --- a/tika-core/src/test/java/org/apache/tika/pipes/async/MockFetcher.java +++ b/tika-core/src/test/java/org/apache/tika/pipes/async/MockFetcher.java @@ -23,6 +23,7 @@ import java.nio.charset.StandardCharsets; import org.apache.tika.exception.TikaException; import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; import org.apache.tika.pipes.fetcher.Fetcher; public class MockFetcher implements Fetcher { @@ -37,7 +38,7 @@ public class MockFetcher implements Fetcher { } @Override - public InputStream fetch(String fetchKey, Metadata metadata) throws TikaException, IOException { + public InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws TikaException, IOException { return new ByteArrayInputStream(BYTES); } } diff --git a/tika-core/src/test/java/org/apache/tika/pipes/fetcher/MockFetcher.java b/tika-core/src/test/java/org/apache/tika/pipes/fetcher/MockFetcher.java index 060432724..e9104e0a8 100644 --- a/tika-core/src/test/java/org/apache/tika/pipes/fetcher/MockFetcher.java +++ b/tika-core/src/test/java/org/apache/tika/pipes/fetcher/MockFetcher.java @@ -29,6 +29,7 @@ import org.apache.tika.config.Param; import org.apache.tika.exception.TikaConfigException; import org.apache.tika.exception.TikaException; import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; public class MockFetcher extends AbstractFetcher implements Initializable { @@ -64,7 +65,7 @@ public class MockFetcher extends AbstractFetcher implements Initializable { @Override - public InputStream fetch(String fetchKey, Metadata metadata) throws TikaException, IOException { + public InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws TikaException, IOException { return byteString == null ? new ByteArrayInputStream(new byte[0]) : new ByteArrayInputStream(byteString.getBytes(StandardCharsets.UTF_8)); } diff --git a/tika-pipes/tika-fetchers/tika-fetcher-az-blob/src/main/java/org/apache/tika/pipes/fetcher/azblob/AZBlobFetcher.java b/tika-pipes/tika-fetchers/tika-fetcher-az-blob/src/main/java/org/apache/tika/pipes/fetcher/azblob/AZBlobFetcher.java index dee903040..6e8dfe7d7 100644 --- a/tika-pipes/tika-fetchers/tika-fetcher-az-blob/src/main/java/org/apache/tika/pipes/fetcher/azblob/AZBlobFetcher.java +++ b/tika-pipes/tika-fetchers/tika-fetcher-az-blob/src/main/java/org/apache/tika/pipes/fetcher/azblob/AZBlobFetcher.java @@ -43,6 +43,7 @@ import org.apache.tika.exception.TikaException; import org.apache.tika.io.TemporaryResources; import org.apache.tika.io.TikaInputStream; import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; import org.apache.tika.pipes.fetcher.AbstractFetcher; import org.apache.tika.utils.StringUtils; @@ -70,7 +71,7 @@ public class AZBlobFetcher extends AbstractFetcher implements Initializable { private boolean spoolToTemp = true; @Override - public InputStream fetch(String fetchKey, Metadata metadata) throws TikaException, IOException { + public InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws TikaException, IOException { LOGGER.debug("about to fetch fetchkey={} from endpoint ({})", fetchKey, endpoint); diff --git a/tika-pipes/tika-fetchers/tika-fetcher-gcs/src/main/java/org/apache/tika/pipes/fetcher/gcs/GCSFetcher.java b/tika-pipes/tika-fetchers/tika-fetcher-gcs/src/main/java/org/apache/tika/pipes/fetcher/gcs/GCSFetcher.java index 6881c5a66..661d5f30d 100644 --- a/tika-pipes/tika-fetchers/tika-fetcher-gcs/src/main/java/org/apache/tika/pipes/fetcher/gcs/GCSFetcher.java +++ b/tika-pipes/tika-fetchers/tika-fetcher-gcs/src/main/java/org/apache/tika/pipes/fetcher/gcs/GCSFetcher.java @@ -39,6 +39,7 @@ import org.apache.tika.exception.TikaException; import org.apache.tika.io.TemporaryResources; import org.apache.tika.io.TikaInputStream; import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; import org.apache.tika.pipes.fetcher.AbstractFetcher; /** @@ -55,7 +56,7 @@ public class GCSFetcher extends AbstractFetcher implements Initializable { private boolean spoolToTemp = true; @Override - public InputStream fetch(String fetchKey, Metadata metadata) throws TikaException, IOException { + public InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws TikaException, IOException { LOGGER.debug("about to fetch fetchkey={} from bucket ({})", fetchKey, bucket); diff --git a/tika-pipes/tika-fetchers/tika-fetcher-http/pom.xml b/tika-pipes/tika-fetchers/tika-fetcher-http/pom.xml index e759879c1..05b296134 100644 --- a/tika-pipes/tika-fetchers/tika-fetcher-http/pom.xml +++ b/tika-pipes/tika-fetchers/tika-fetcher-http/pom.xml @@ -45,6 +45,10 @@ <artifactId>tika-httpclient-commons</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>tika-core</artifactId> @@ -127,4 +131,4 @@ <scm> <tag>3.0.0-BETA-rc1</tag> </scm> -</project> \ No newline at end of file +</project> diff --git a/tika-pipes/tika-fetchers/tika-fetcher-http/src/main/java/org/apache/tika/pipes/fetcher/http/HttpFetcher.java b/tika-pipes/tika-fetchers/tika-fetcher-http/src/main/java/org/apache/tika/pipes/fetcher/http/HttpFetcher.java index 26b45f8bf..af38eb19f 100644 --- a/tika-pipes/tika-fetchers/tika-fetcher-http/src/main/java/org/apache/tika/pipes/fetcher/http/HttpFetcher.java +++ b/tika-pipes/tika-fetchers/tika-fetcher-http/src/main/java/org/apache/tika/pipes/fetcher/http/HttpFetcher.java @@ -24,6 +24,7 @@ import java.net.InetAddress; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; +import java.net.http.HttpHeaders; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -60,13 +61,13 @@ import org.apache.tika.config.Initializable; import org.apache.tika.config.InitializableProblemHandler; import org.apache.tika.config.Param; import org.apache.tika.exception.TikaConfigException; -import org.apache.tika.exception.TikaException; import org.apache.tika.exception.TikaTimeoutException; import org.apache.tika.io.TemporaryResources; import org.apache.tika.io.TikaInputStream; import org.apache.tika.metadata.Metadata; import org.apache.tika.metadata.Property; import org.apache.tika.metadata.TikaCoreProperties; +import org.apache.tika.parser.ParseContext; import org.apache.tika.pipes.fetcher.AbstractFetcher; import org.apache.tika.pipes.fetcher.RangeFetcher; import org.apache.tika.utils.StringUtils; @@ -136,7 +137,7 @@ public class HttpFetcher extends AbstractFetcher implements Initializable, Range @Override - public InputStream fetch(String fetchKey, Metadata metadata) throws IOException, TikaException { + public InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws IOException { HttpGet get = new HttpGet(fetchKey); RequestConfig requestConfig = RequestConfig.custom() @@ -150,12 +151,17 @@ public class HttpFetcher extends AbstractFetcher implements Initializable, Range } @Override - public InputStream fetch(String fetchKey, long startRange, long endRange, Metadata metadata) + public InputStream fetch(String fetchKey, long startRange, long endRange, Metadata metadata, ParseContext parseContext) throws IOException { HttpGet get = new HttpGet(fetchKey); if (! StringUtils.isBlank(userAgent)) { get.setHeader(USER_AGENT, userAgent); } + HttpHeaders headers = parseContext.get(HttpHeaders.class); + if (headers != null) { + + } + get.setHeader("Range", "bytes=" + startRange + "-" + endRange); return execute(get, metadata, httpClient, true); } @@ -455,4 +461,11 @@ public class HttpFetcher extends AbstractFetcher implements Initializable, Range this.httpClientFactory = httpClientFactory; } + public void setHttpClient(HttpClient httpClient) { + this.httpClient = httpClient; + } + + public HttpClient getHttpClient() { + return httpClient; + } } diff --git a/tika-pipes/tika-fetchers/tika-fetcher-http/src/main/java/org/apache/tika/pipes/fetcher/http/config/AdditionalHttpHeaders.java b/tika-pipes/tika-fetchers/tika-fetcher-http/src/main/java/org/apache/tika/pipes/fetcher/http/config/AdditionalHttpHeaders.java new file mode 100644 index 000000000..354e7b33a --- /dev/null +++ b/tika-pipes/tika-fetchers/tika-fetcher-http/src/main/java/org/apache/tika/pipes/fetcher/http/config/AdditionalHttpHeaders.java @@ -0,0 +1,49 @@ +package org.apache.tika.pipes.fetcher.http.config; + +import java.util.Collection; +import java.util.Map; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; + +public class AdditionalHttpHeaders { + @JsonIgnore + private Multimap<String, String> headers = ArrayListMultimap.create(); + + @JsonIgnore + public Multimap<String, String> getHeaders() { + return headers; + } + + public Map<String, Collection<String>> getMap() { + return headers.asMap(); + } + + public void setMap(Map<String, Collection<String>> map) { + headers = ArrayListMultimap.create(); + map.forEach(headers::putAll); + } + + public void setHeaders(Multimap<String, String> headers) { + this.headers = headers; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalHttpHeaders that = (AdditionalHttpHeaders) o; + return Objects.equals(headers, that.headers); + } + + @Override + public int hashCode() { + return Objects.hash(headers); + } +} diff --git a/tika-pipes/tika-fetchers/tika-fetcher-http/src/test/java/org/apache/tika/pipes/fetcher/http/HttpFetcherTest.java b/tika-pipes/tika-fetchers/tika-fetcher-http/src/test/java/org/apache/tika/pipes/fetcher/http/HttpFetcherTest.java index e26e6cfcb..5a461e811 100644 --- a/tika-pipes/tika-fetchers/tika-fetcher-http/src/test/java/org/apache/tika/pipes/fetcher/http/HttpFetcherTest.java +++ b/tika-pipes/tika-fetchers/tika-fetcher-http/src/test/java/org/apache/tika/pipes/fetcher/http/HttpFetcherTest.java @@ -37,13 +37,20 @@ import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; +import org.apache.http.ProtocolVersion; import org.apache.http.StatusLine; import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HttpContext; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; import org.apache.tika.TikaTest; import org.apache.tika.client.HttpClientFactory; @@ -51,7 +58,9 @@ import org.apache.tika.exception.TikaException; import org.apache.tika.io.TemporaryResources; import org.apache.tika.metadata.Metadata; import org.apache.tika.metadata.TikaCoreProperties; +import org.apache.tika.parser.ParseContext; import org.apache.tika.pipes.fetcher.FetcherManager; +import org.apache.tika.pipes.fetcher.http.config.AdditionalHttpHeaders; public class HttpFetcherTest extends TikaTest { @@ -131,6 +140,45 @@ public class HttpFetcherTest extends TikaTest { } } + @Test + public void testHttpRequestHeaders() throws Exception { + HttpClient httpClient = Mockito.mock(HttpClient.class); + httpFetcher.setHttpClient(httpClient); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + ArgumentCaptor<HttpGet> httpGetArgumentCaptor = ArgumentCaptor.forClass(HttpGet.class); + + when(httpClient.execute(httpGetArgumentCaptor.capture(), any(HttpContext.class))) + .thenReturn(response); + when(response.getStatusLine()).thenReturn(new StatusLine() { + @Override + public ProtocolVersion getProtocolVersion() { + return new HttpGet("http://localhost").getProtocolVersion(); + } + + @Override + public int getStatusCode() { + return 200; + } + + @Override + public String getReasonPhrase() { + return null; + } + }); + + when(response.getEntity()).thenReturn(new StringEntity("Hi")); + + Metadata metadata = new Metadata(); + ParseContext parseContext = new ParseContext(); + AdditionalHttpHeaders additionalHttpHeaders = new AdditionalHttpHeaders(); + additionalHttpHeaders.getHeaders().put("nick1", "val1"); + additionalHttpHeaders.getHeaders().put("nick2", "val2"); + parseContext.set(AdditionalHttpHeaders.class, additionalHttpHeaders); + httpFetcher.fetch("http://localhost", metadata); + HttpGet httpGet = httpGetArgumentCaptor.getValue(); + Assertions.assertEquals("val1", httpGet.getHeaders("nick1")[0].getValue()); + Assertions.assertEquals("val2", httpGet.getHeaders("nick2")[0].getValue()); + } FetcherManager getFetcherManager(String path) throws Exception { return FetcherManager.load( diff --git a/tika-pipes/tika-fetchers/tika-fetcher-http/src/test/java/org/apache/tika/pipes/fetcher/http/config/AdditionalHttpHeadersTest.java b/tika-pipes/tika-fetchers/tika-fetcher-http/src/test/java/org/apache/tika/pipes/fetcher/http/config/AdditionalHttpHeadersTest.java new file mode 100644 index 000000000..7a6d8b7b7 --- /dev/null +++ b/tika-pipes/tika-fetchers/tika-fetcher-http/src/test/java/org/apache/tika/pipes/fetcher/http/config/AdditionalHttpHeadersTest.java @@ -0,0 +1,24 @@ +package org.apache.tika.pipes.fetcher.http.config; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; + +class AdditionalHttpHeadersTest { + + ObjectMapper om = new ObjectMapper(); + + @Test + void testToAndFromJson() throws JsonProcessingException { + AdditionalHttpHeaders additionalHttpHeaders = new AdditionalHttpHeaders(); + additionalHttpHeaders.getHeaders().put("nick1", "val1"); + additionalHttpHeaders.getHeaders().put("nick2", "val2"); + + String json = om.writeValueAsString(additionalHttpHeaders); + + AdditionalHttpHeaders additionalHttpHeaders2 = om.readValue(json, AdditionalHttpHeaders.class); + assertEquals(additionalHttpHeaders, additionalHttpHeaders2); + } +} diff --git a/tika-pipes/tika-fetchers/tika-fetcher-s3/src/main/java/org/apache/tika/pipes/fetcher/s3/S3Fetcher.java b/tika-pipes/tika-fetchers/tika-fetcher-s3/src/main/java/org/apache/tika/pipes/fetcher/s3/S3Fetcher.java index b57c361b9..7283c9727 100644 --- a/tika-pipes/tika-fetchers/tika-fetcher-s3/src/main/java/org/apache/tika/pipes/fetcher/s3/S3Fetcher.java +++ b/tika-pipes/tika-fetchers/tika-fetcher-s3/src/main/java/org/apache/tika/pipes/fetcher/s3/S3Fetcher.java @@ -55,6 +55,7 @@ import org.apache.tika.io.FilenameUtils; import org.apache.tika.io.TemporaryResources; import org.apache.tika.io.TikaInputStream; import org.apache.tika.metadata.Metadata; +import org.apache.tika.parser.ParseContext; import org.apache.tika.pipes.fetcher.AbstractFetcher; import org.apache.tika.pipes.fetcher.RangeFetcher; import org.apache.tika.utils.StringUtils; @@ -106,12 +107,12 @@ public class S3Fetcher extends AbstractFetcher implements Initializable, RangeFe private boolean pathStyleAccessEnabled = false; @Override - public InputStream fetch(String fetchKey, Metadata metadata) throws TikaException, IOException { + public InputStream fetch(String fetchKey, Metadata metadata, ParseContext parseContext) throws TikaException, IOException { return fetch(fetchKey, -1, -1, metadata); } @Override - public InputStream fetch(String fetchKey, long startRange, long endRange, Metadata metadata) + public InputStream fetch(String fetchKey, long startRange, long endRange, Metadata metadata, ParseContext parseContext) throws TikaException, IOException { String theFetchKey = StringUtils.isBlank(prefix) ? fetchKey : prefix + fetchKey;
