Extract from non-filesystem sources
masterExtract queries are not limited to local files. You can provide various types of input via $query->setFile():
- Remote URLs: Pass a stream URL (e.g.,
http://example.org/resource). Note that remote streaming is disabled by default in Solr. - Memory Streams: Use PHP wrappers like
php://memoryorphp://temp. This is useful for content generated in-memory. - Temporary Files: Use
tmpfile()to create a temporary file, write content to it, and pass the file pointer. - Database LOBs: Pass a PDO Large Object (LOB) stream.
Note: Using a LOB as a stream requires PHP 8.1.0 or higher due to PHP Bug #40913.
// Example: Using a memory stream
$contents = '...';
$file = fopen('php://memory', 'w+');
fwrite($file, $contents);
$query->setFile($file);
$client->extract($query);
fclose($file);