gridfs

Unable to write buffer to MongoDB GridFS

假如想象 提交于 2019-12-24 13:19:44
问题 Hi guys i have spent almost a day trying to figure this one out. I'm using multer's inMemory flag to upload an image from my webpage. The obvious attempt is to write the buffer received from multer to GridFs (GridStore more specifically). here is my multer code product.js (route/controller) var DB = rek('database'); var router = express.Router(); var multer = require("multer"); var uploadOptions = {inMemory:true, onFileUploadComplete: uploadDone} router.post('/product/:productId/images/',

GridFS : How to display the result of readstream.pipe(res) in an <img/> tag?

≯℡__Kan透↙ 提交于 2019-12-24 06:32:10
问题 I am using MangoDB along with GridFS to store images. I've got this route to retrieve an image from the DB : app.get("/images/profile/:uId", function (req, res) { let uId = req.params.uId; console.log(uId) gfs.files.findOne( { "metadata.owner": uId, "metadata.type": 'profile' } , function (err, file) { if (err || !file) { return res.status(404).send({ error: 'Image not found' }); } var readstream = gfs.createReadStream({ filename: file.filename }); readstream.on("error", function (err) { res

Retrieving images from GridFS using django-tastypie-mongoengine

前提是你 提交于 2019-12-24 03:42:48
问题 I have a project in Django, and I'm using mongoengine to save images into a Mongo database using GridFSStorage. All ok so far, but the problem is... when trying to retrieve the images via http request, with a REST API made with django-tastypie-mongoengine, I get back a json object like this: {"file": "<GridFSProxy: 516ed7cf56ba7d01eb09f522>", "id": "516ed7cf56ba7d01eb09f524", "resource_uri": "/api/v1/pic/516ed7cf56ba7d01eb09f524/"} Does anybody know how could I get the file from GridFS via

How to retrieve all images from gridFs in a single http Request

旧巷老猫 提交于 2019-12-24 03:40:00
问题 I am new in mean.js(angular.js+node.js) and using GridFs to store images. In order to retrieve the images now i am sending a http request for each image. I am worried about the fact that whether it will affect the speed of the site. So i want to retrieve all images together From gridFs. Is that possible? can anybody help me? below provided is my client side code. $http.get('/uploads?filename=' + imagename).success(function(response) { $scope.img.push({imageph: response, image: item.image, url

MeteorJS - Linking images (FS.collection) to their relevant document in the MongoDB Collection

自闭症网瘾萝莉.ら 提交于 2019-12-23 05:40:43
问题 I'm building an app with Meteorjs. I have a collection that is initialized as: Places=new Mongo.Collection('places'); in which I also want to store the images of the corresponding place. I've added the collectionFS package to my project. The following code creates a separate collection for the images: image=new FS.Collection("images", { stores: [new FS.Store.FileSystem("images")] }); However, I fail to understand how am I supposed to associate this set of images to its relevant document in

How can one add text files in Mongodb?

只谈情不闲聊 提交于 2019-12-23 04:19:12
问题 I have certain requirement to insert a text file in mongodb, retrieve it back and then check that whether files are same. I am hoping to do it without GridFS as the files i want to use is lesser than 16MB, so can you guys plz suggest me ways to do it, considering that set up of mongodb is very basic one. Thanks 回答1: A text file that is less than 16 MB can be stored as a simple key-value pair in a plain document. No need for GridFS and no need for Binary or JSON objects. If in doubt, try it.

Spring display image in jsp from MongoDB

▼魔方 西西 提交于 2019-12-23 04:12:23
问题 I need to get an image from MongoDB GridFS system, then displaying it in a JSP img tag. This is my code that isnt working: @RequestMapping(value = "/getPhoto", method = RequestMethod.GET) public @ResponseBody void getPhoto(HttpServletRequest request, HttpServletResponse response) { try { System.out.println("getting photo..."); GridFSDBFile imageForOutput = userFacade.loadProfilePhoto((User) SecurityContextHolder.getContext().getAuthentication() .getPrincipal()); BufferedImage image = ImageIO

Saving Files to MongoDB GridFS with Node.JS

牧云@^-^@ 提交于 2019-12-23 02:57:09
问题 How do you put the close() in the writeBuffer callback? This question relates to: Problem with MongoDB GridFS Saving Files with Node.JS 回答1: A simple example is https://github.com/mongodb/node-mongodb-native/blob/master/test/gridstore/grid_store_test.js#L97 Also check the docs for changes in behavior, writeBuffer was removed so just use write. http://mongodb.github.com/node-mongodb-native/ 来源: https://stackoverflow.com/questions/10092282/saving-files-to-mongodb-gridfs-with-node-js

MongoDB - Populate GridFS files metadata in parent document

左心房为你撑大大i 提交于 2019-12-23 01:13:49
问题 I am using NodeJS with Express, MongoDB, Mongoose and GridFS for uploading and retrieving files. I would like to reference files in other documents by ID and populate the files metadata when querying the other documents. For example: If I have a collection "users" with documents like this ... { _id: ObjectId("554dfeb59e78d9081af2404f"), name: "John Doe", image: ObjectId("55b61ae329c44b483665bafc") } ... I want to do somethig like this ... User.findById(req.params.id) .populate('image') .exec

Express file upload with multer and gridfs (corrupted file ?)

杀马特。学长 韩版系。学妹 提交于 2019-12-22 10:39:39
问题 I'm trying to upload a file (an image), the upload is fine, the file is stored in Mongo and have the same content type and same size as the original file, then when I try to download it, the file is corrupted but keeps the same content type (if I upload a pdf, it is recognized as a pdf, if it is a png, it is also recognized, but I can't open them). I don't understand what is wrong with this, it is pretty simple and standard. For the upload from the client, I use angular ng-upload, for the