问题
for a better distribution of files in a sharded Mongo GridFs I'd like to create my own files_id. How this can be done in Java is described here:
http://groups.google.com/group/mongodb-user/msg/524bae1602770587
But how to do this in PHP? I could find no hint in the API documentation, I use storeBytes for saving the files:
http://www.php.net/manual/en/mongogridfs.storebytes.php
回答1:
You should be able to just set this in the "$extra" argument with the "_id" key, something like:
$m = new Mongo; $db = $m->phpunit; $grid = $db->GetGridFS(); $grid->storeBytes("testing", array("_id" => "MYID", "filename" => "test.txt"));
cheers, Derick
来源:https://stackoverflow.com/questions/8907050/create-own-files-id-in-mongo-gridfs-using-php