gridfs

MongoDB as static files provider?

时光怂恿深爱的人放手 提交于 2019-12-20 14:48:19
问题 It's MongoDB a good candidate to serve static files (files, video) as cdn. I searching a solid way to store big amounts of data (>+To) remplacing S3 and managing cache features. Experiences. Thanks. 回答1: I suppose that the answer to this question is no , because when you are using a CDN to store static files you make your server free from static data requests. But when you are choosing between a file system and mongodb Ii suppose that mongodb will be faster, beacause if there is enough ram on

how to download a file saved in gridFS using nodeJS

北战南征 提交于 2019-12-19 09:08:09
问题 I need to download a resume from GridFS, below is the code ive written to do it, but this seems to not give me a physical file for download, this is used to reading the contents. How can i download the file? exports.getFileById = function(req, res){ var conn = mongoose.connection; var gfs = Grid(conn.db, mongoose.mongo); var id = req.params.ID; gfs.exist({_id: id,root: 'resume'}, function (err, found) { if (err) return handleError(err); if (!found) return res.send('Error on the database

GridFS support in MongoAPI of Azure DocumentDB

雨燕双飞 提交于 2019-12-18 17:26:16
问题 I am using the MongoDB API for DocumentDB via the GridFsTemplate from springdata in JAVA. I am getting an error when trying to use the GridFS part of MongoDB to manage large files. I am able to create a file (I think) and find its metadata, but I cannot retrieve the file contents. The following error is returned: Error: error: { "_t" : "OKMongoResponse", "ok" : 0, "code" : 8, "errmsg" : "The value '/media/7hsUAJOI2QsBAAAAAAAAAEeWwrcB' specified for query '$resolveFor' is invalid.\r

How to use GridFS to store images using Node.js and Mongoose

不问归期 提交于 2019-12-18 11:29:33
问题 I am new to Node.js. Can anyone provide me an example of how to use GridFS for storing and retrieving binary data, such as images, using Node.js and Mongoose? Do I need to directly access GridFS? 回答1: I was not satisfied with the highest rated answer here and so I'm providing a new one: I ended up using the node module 'gridfs-stream' (great documentation there!) which can be installed via npm. With it, and in combination with mongoose, it could look like this: var fs = require('fs'); var

Sails.js checking stuff before uploading files to MongoDB with skipper (valid files, image resizing etc)

▼魔方 西西 提交于 2019-12-18 04:23:13
问题 I'm currently creating a file upload system in my application. My backend is Sails.js (10.4), which serves as an API for my separate front-end (Angular). I've chosen to store the files I'm uploading to my MongoDB instance, and using sails' build in file upload module Skipper. I'm using the adapter skipper-gridfs (https://github.com/willhuang85/skipper-gridfs) to upload the files to mongo. Now, it's not a problem to upload the files themselves: I'm using dropzone.js on my client, which sends

Problem with MongoDB GridFS Saving Files with Node.JS

纵饮孤独 提交于 2019-12-17 19:29:40
问题 I have a function saving a file to gridfs. It somehow stopped working sporadically after a refactor and I've spent over 2 hours staring blankly at it. I swear it's roughly the same as it was. I seem to remember it not working at first before I added close, then it started working, but it could be the insomnia. Essentially the issue is the db.fs.files collection doesn't have any records, but chunks are getting added to db.fs.chunks. data is a buffer loaded from disk via fs.readFile() 31 var gs

Read chunk from Gridfs and convert to Buffer

江枫思渺然 提交于 2019-12-14 02:20:24
问题 I got a question about buffer. Here is my code: var Grid = require('gridfs-stream'); var mongodb = require('mongodb'); var gfs = Grid(db, mongodb); var deferred = Q.defer(); var image_buf = new Buffer('buffer'); var readableStream = gfs.createReadStream(name); readableStream.on('data',function(chunk){ console.log(chunk); image_buf = Buffer.concat([image_buf, chunk]); console.log(image_buf)//differ from the chunk above }); readableStream.on('end',function(){ db.close(); deferred.resolve(image

How to reference GridFSFile with @DbRef annotation (spring data mongodb)

蓝咒 提交于 2019-12-13 14:34:20
问题 i have a spring @Document object Profile i would like to reference GridFSFile like it : @DbRef private GridFSFile file; the file is writen into another collection type GridFS. I always have a java.lang.StackOverflowError when i set profile.setFile(file); java.lang.StackOverflowError at org.springframework.util.ObjectUtils.nullSafeHashCode(ObjectUtils.java:336) at org.springframework.data.util.TypeDiscoverer.hashCode(TypeDiscoverer.java:365) at org.springframework.data.util

MongoDB GridFS store multiple sizes of image or use on the fly resizing

余生长醉 提交于 2019-12-13 12:35:12
问题 In my web app i'm using MongoDB GridFS to store user uploaded images. The rest of the site is managed by MySQL. In a photo table (in mysql) I have three fields for storing the MongoId of the file object. small medium large So I store three versions of the image. Small, medium and large. My question is, sometimes i'll need to use a thumbnail smaller than the 'small' version of the image (i.e. in a widget box, message avatars etc.) or i'll need to use a slighly smaller version of the medium

How should I design my data storage scheme using mongoDB?

不打扰是莪最后的温柔 提交于 2019-12-13 05:15:15
问题 My data is like belows : I have about 1,000,000 gene sequence data ,but some of them are very short ,hundreds of characters , but some of them is so large that its BSON size has already exceeds the 16M per-document size limit of MongoDB ,up to about 10,000,000 charactors for one sequence. So ,I am considering using GridFS to store these sequence as a file.So , I fall into a delima: solution 1:store all gene sequence as files using GridFS, no matter they are small or big. solution 2:only store