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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -