Extract query setFile() without storing the file on local storage #1066
-
I am getting files from database in blob format and I want to send them to Solr Cell using extract query. However, the setFile() method in the Extract Query expects a local file path as input, but I want to avoid saving the binary file to the local storage before sending it to Solr instead I want to pass a binary file directly. Is it possible somehow to send a binary file directly with extract query or is there some better approach to this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I've opened an issue for this. It's not possible at the moment, but it's an easy fix. |
Beta Was this translation helpful? Give feedback.
-
Solarium 6.3.1 lets you extract from file pointer resources. This means you can now store data in memory instead of a file. $file = fopen('php://memory', 'w+');
fwrite($file, $blob);
$extract->setFile($file);
$client->extract($extract);
fclose($file); Check the PHP manual on php://memory and php://temp for more details. I think you can also use PDO Large Objects to do it directly, but I haven't tested this. |
Beta Was this translation helpful? Give feedback.
I tested it and this does work in PHP >= 8.1.0. It generates warnings with Solarium 6.3.1 though. I've opened PR #1083 to have this fixed in the next release. The PR also includes a full working example.