java - JSON to BSON ObjectID -
i want insert image files in mongodb gridfsbucket custom id.
my code:
public int uploaddocument(string file, string file_id) throws filenotfoundexception { gridfsbucket gridfsfilesbucket = gridfsbuckets.create(database,"files"); string path=file_dir.concat(file); inputstream streamtouploadfrom = new fileinputstream(new file(path)); gridfsuploadoptions options = new gridfsuploadoptions() .chunksizebytes(358400) .metadata(new document("type", "presentation")); gridfsfilesbucket.uploadfromstream(file_id, file, streamtouploadfrom); }
i using below method files upload in gridfsbucket. openuploadstream(bsonvalue id, string filename, gridfsuploadoptions options)
how custom bsonvalue pass id method?
Comments
Post a Comment