I am building a site where I need to store encrypted images in the database.
This works perfectly however now I need to programmatically import thousands of photos.
I'm using this code to attach images to nodes:
$nid = 100; $node = node_load($nid); $image_path = '/var/www/coach/htdocs/photos/test.jpg'; $file = (object) array( 'uid' => 1, 'uri' => $image_path, 'filemime' => file_get_mimetype($image_path), 'status' => 1, 'display' => 1 ); $destination = 'private://'; $file = file_copy($file, $destination, FILE_EXISTS_REPLACE); $node->field_passport_photo[LANGUAGE_NONE] = (array) $file; node_save($node);
However the destination here is wrong - I don't want to use the private scheme - I want to save the file to the database using the Storage API.
The documentation says that $destination is "A string containing the destination that $source should be copied to. This must be a stream wrapper URI."
After manually adding an image to a node and inspecting the $form item on the edit form page I can see that the #upload_location of the image is "storage-field-passport-photo://", however just passing this string into file_copy as a destination does not work as a valid file object is not returned.
So, what is the stream wrapper URI to get the file to be saved to the database?