gridfs

Could not Upload File using MongoDb GridFs

拈花ヽ惹草 提交于 2020-01-06 03:53:25
问题 I'm new to Spring-Boot,i'm trying to upload file to Mongodb Database, save its objectId and link it to my document, in order to download it Later. Here is my class Person: @Document public class Person { @Id private String id; private String firstName; private String lastName; private String age; private String filename; private ObjectId file; ....} This is my controller method: @RequestMapping(value="/addperson",method=RequestMethod.POST) public String ajout(Model model,@Valid PersonForm pf)

Read data from MongoDB (gridfs) via Matlab and Java driver

放肆的年华 提交于 2020-01-05 11:37:06
问题 I am working with Matlab and the Java driver. After writing some big data to the DB I want to read them out later. The files are about 100MB big and because of that I am writing them into GridFS. I read the data with the Java driver into Matlab this way: dbgridfs = GridFS(db, 'data_gridfs'); file1 = dbgridfs.findOne('bigdata'); After that code I will get an object in my Matlab workspace: Name Size Bytes Class file1 1x1 com.mongodb.gridfs.GridFSDBFile Now I have a problem with converting the

RS102 MongoDB on ReplicaSet

那年仲夏 提交于 2020-01-01 17:26:20
问题 I have set up a replica set with 4 servers. For testing purpose, I wrote a script to fill my database up to ~150 millions rows of photos using GridFS. My photos are around ~15KB. (This shouldn't be a problem to use gridfs for small files ?!) After after a few hours, there were around 50 millions rows, but I had this message in the logs : replSet error RS102 too stale to catch up, at least from 192.168.0.1:27017 And here is the replSet status : rs.status(); { "set" : "rsdb", "date" : ISODate(

Query on MongoDB GridFS metadata (Java)

邮差的信 提交于 2019-12-30 04:17:30
问题 What I'm trying to do is fetching a list of GridFS files by querying an field of the metadata. For example I got a GridFS file document looking like: { "_id" : { "$oid" : "4f95475f5ef4fb269dbac954"} , "chunkSize" : 262144 , "length" : 3077 , "md5" : "f24ea7ac05c5032f08808c6faabf413b" , "filename" : "file_xyz.txt" , "contentType" : null , "uploadDate" : { "$date" : "2012-04-23T12:13:19.606Z"} , "aliases" : null , "metadata" : { "target_field" : "abcdefg"}} And I want to query all files

Append data to existing gridfs file

ⅰ亾dé卋堺 提交于 2019-12-29 08:07:12
问题 As i can see java mongo driver does not provide capability to get OutputStream from existing gridFS file com.mongodb.gridfs.GridFSFile I have to create GridFSInputFile directly or use gridFs.createFile() method. Is it a lack of java driver or a restriction of gridfs ? Could you suggest any workaround except create new file/delete old one ? Thank you 回答1: GridFS is not a core feature of MongoDB but a convention of storing binary data with accompanying metadata. You should be able to modify any

How to chain write stream, immediately with a read stream in Node.js 0.10?

心不动则不痛 提交于 2019-12-29 06:44:10
问题 The following line will download an image file from a specified url variable: var filename = path.join(__dirname, url.replace(/^.*[\\\/]/, '')); request(url).pipe(fs.createWriteStream(filename)); And these lines will take that image and save to MongoDB GridFS: var gfs = Grid(mongoose.connection.db, mongoose.mongo); var writestream = gfs.createWriteStream({ filename: filename }); fs.createReadStream(filename).pipe(writestream); Chaining pipe like this throws Error: 500 Cannot Pipe. Not

Sending chunked files to save in mongodb

南笙酒味 提交于 2019-12-25 17:54:13
问题 I have 2 different servers for example (Server 1 , Server 2), In the first server I have golang app which splits files and sending to second server which should save in mongodb via mgo.v2 Server 1: func mainHandle(rw http.ResponseWriter, rq *http.Request) { fileToBeChunked := "/Users/IT/Desktop/4k.jpg" file, err := os.Open(fileToBeChunked) if err != nil { fmt.Println(err) os.Exit(1) } defer file.Close() fileInfo, _ := file.Stat() var fileSize int64 = fileInfo.Size() const fileChunk = 0.25 *

Sending chunked files to save in mongodb

醉酒当歌 提交于 2019-12-25 17:53:08
问题 I have 2 different servers for example (Server 1 , Server 2), In the first server I have golang app which splits files and sending to second server which should save in mongodb via mgo.v2 Server 1: func mainHandle(rw http.ResponseWriter, rq *http.Request) { fileToBeChunked := "/Users/IT/Desktop/4k.jpg" file, err := os.Open(fileToBeChunked) if err != nil { fmt.Println(err) os.Exit(1) } defer file.Close() fileInfo, _ := file.Stat() var fileSize int64 = fileInfo.Size() const fileChunk = 0.25 *

Spring adding multiple GridFS templates in servlet-context.xml

大憨熊 提交于 2019-12-24 19:27:08
问题 I am new bie to Spring framework. I am planning use to use two gridfs templates for my next project. I want to use two different databases "ProductImage" and "ProfileImage". Depending on image uploaded by user image should be inserted in relevant database. So I am trying to configure my application-context.xml as follows <!-- Mongo GridFs settings --> <!-- Connection to MongoDB server --> <mongo:db-factory host="192.168.1.3" port="27017" dbname="ProfileImages" /> <mongo:mapping-converter id=

How to link to an image in GridFS in an <img> tag?

早过忘川 提交于 2019-12-24 16:19:36
问题 We can think about how serving a list of images works in HTML. When we serve a page it includes tags that reference an image and then the browser makes a separate request to get each one. This works well with mongodb. We can just serve the page and insert tags like <img src="/profile_pics/userid"> and then our server just redirects that path to the GridFS file with {"profile_pic": userid} . Source : http://www.markus-gattol.name/ws/mongodb.html I have tried: HTML <li> <img src="/static/img