File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,11 @@ You can use an URL instead of a file path and the library will download the file
122
122
** no need** to add ` -enableUnsecureFeatures -enableFileUrl ` to command line when starting the server, as described
123
123
[ here] ( https://wiki.apache.org/tika/TikaJAXRS#Specifying_a_URL_Instead_of_Putting_Bytes ) .
124
124
125
+ If you use Apache Tika >= 2.0.0, you * can* [ define an HttpFetcher] ( https://cwiki.apache.org/confluence/display/TIKA/tika-pipes )
126
+ and use the option ` -enableUnsecureFeatures -enableFileUrl ` when starting the server to make the server download remote
127
+ files when passing a URL instead of a filname to ` $client->getText() ` . In order to do so, you must set the name of
128
+ the HttpFetcher using ` $client->setFetcherName('yourFetcherName') ` .
129
+
125
130
### Methods
126
131
127
132
Here are the full list of available methods
@@ -254,6 +259,12 @@ $client->setOCRLanguages($languages);
254
259
$client->getOCRLanguages();
255
260
```
256
261
262
+ Set HTTP fetcher name (for Tika >= 2.0.0 only, see https://cwiki.apache.org/confluence/display/TIKA/tika-pipes )
263
+
264
+ ``` php
265
+ $client->setFetcherName($fetcherName)
266
+ ```
267
+
257
268
### Breaking changes
258
269
259
270
Since 1.0 version there are some breaking changes:
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ class WebClient extends Client
51
51
*/
52
52
protected $ retries = 3 ;
53
53
54
+ /**
55
+ * Name of the fetcher to be used (for Tika >= 2.0.0 only)
56
+ *
57
+ * @var string|null
58
+ */
59
+ protected $ fetcherName = null ;
60
+
54
61
/**
55
62
* Default cURL options
56
63
*
@@ -208,6 +215,16 @@ public function setRetries(int $retries): self
208
215
return $ this ;
209
216
}
210
217
218
+ /**
219
+ * Set the name of the fetcher to be used (for Tika >= 2.0.0 only)
220
+ */
221
+ public function setFetcherName (string $ fetcherName ): self
222
+ {
223
+ $ this ->fetcherName = $ fetcherName ;
224
+
225
+ return $ this ;
226
+ }
227
+
211
228
/**
212
229
* Get all the options
213
230
*/
@@ -626,7 +643,12 @@ protected function getParameters(string $type, string $file = null): array
626
643
627
644
if (!empty ($ file ) && preg_match ('/^http/ ' , $ file ))
628
645
{
629
- $ headers [] = "fileUrl: $ file " ;
646
+ if ($ this ->fetcherName ) {
647
+ $ headers [] = "fetcherName: $ this ->fetcherName " ;
648
+ $ headers [] = "fetchKey: $ file " ;
649
+ } else {
650
+ $ headers [] = "fileUrl: $ file " ;
651
+ }
630
652
}
631
653
632
654
switch ($ type )
You can’t perform that action at this time.
0 commit comments