gridfs-stream

How to send an retrieved image from Mongo using GridFS in Spring Rest Call?

限于喜欢 提交于 2019-12-03 08:49:10
I have retrieved the image from Mongo DB using Spring Data and GridFs Template so i don't know how to serve that retrieved input stream back to user . Say they requested for the http://host.com/apple as a spring rest call . Now my application process the request by using the name apple it retrieves the apple image from a mongodb database . Now without saving anywhere i want to display the response as an image to user that will show http://host.com/apple image in the browser. How exactly i need to implement this ? Could you please share any code repository for processing the image request in

passing mongoose as an argument to a function

天涯浪子 提交于 2019-12-02 17:32:14
问题 I'm developing a node module. I need to pass the mongoose to my module to get three things ( mongoose.connection , mongoose.connection.db , mongoose.mongo ) out of it. index.js (myModule - the module I developed) function myModule(mongoose) { var db = mongoose.connection; var gfs = gridfsLockingStream(mongoose.connection.db, mongoose.mongo); this.someFunction = function() {//some code here} } module.exports = myModule; db.js (A user must use myModule like this) var mongoose = require(

passing mongoose as an argument to a function

送分小仙女□ 提交于 2019-12-02 12:40:53
I'm developing a node module. I need to pass the mongoose to my module to get three things ( mongoose.connection , mongoose.connection.db , mongoose.mongo ) out of it. index.js (myModule - the module I developed) function myModule(mongoose) { var db = mongoose.connection; var gfs = gridfsLockingStream(mongoose.connection.db, mongoose.mongo); this.someFunction = function() {//some code here} } module.exports = myModule; db.js (A user must use myModule like this) var mongoose = require('mongoose'); var myModule = require('myModule'); var dbUrl = 'mongodb://localhost:27017/gfsTestDB'; mongoose

Reading and Displaying images from mongoDB using GridFs

耗尽温柔 提交于 2019-11-30 23:27:17
I have been able to successfully upload images to mongoDB using GridFs. Below are images from my database: fs.files: fs.chunks: Below is the code I used to upload images: var Grid = require('gridfs-stream'); var mongoose = require("mongoose"); Grid.mongo = mongoose.mongo; var gfs = new Grid(mongoose.connection.db); app.post('/picture', function(req, res) { var part = req.files.filefield; var writeStream = gfs.createWriteStream({ filename: part.name, mode: 'w', content_type:part.mimetype }); writeStream.on('close', function() { return res.status(200).send({ message: 'Success' }); });

MongoError when uploading a file using mongoose, gridfs-stream and multer

不问归期 提交于 2019-11-30 10:22:27
I am running express 4 using multer , gridfs-stream and mongoose with mongodb and I am attempting to upload a file and stream it to gridfs. The express route that does this is defined as: app.post('/uploadfile', function (req, res) { console.dir(req.files); // The mongodb instance created when the mongoose.connection is opened var db = mongoose.connection.db; // The native mongo driver which is used by mongoose var mongoDriver = mongoose.mongo; // Create a gridfs-stream var gfs = new Gridfs(db, mongoDriver); var file = req.files.myFile; var fileId = new ObjectId(); console.log("Creating

MongoError when uploading a file using mongoose, gridfs-stream and multer

可紊 提交于 2019-11-29 15:35:08
问题 I am running express 4 using multer, gridfs-stream and mongoose with mongodb and I am attempting to upload a file and stream it to gridfs. The express route that does this is defined as: app.post('/uploadfile', function (req, res) { console.dir(req.files); // The mongodb instance created when the mongoose.connection is opened var db = mongoose.connection.db; // The native mongo driver which is used by mongoose var mongoDriver = mongoose.mongo; // Create a gridfs-stream var gfs = new Gridfs(db

Node.js File Upload (Express 4, MongoDB, GridFS, GridFS-Stream)

那年仲夏 提交于 2019-11-27 16:29:42
问题 I am trying to setup a file API in my node.js application. My goal is to be able to write the file stream directly to gridfs, without needing to store the file to disk initially. It seems like my create code is working. I am able to save a file upload to gridfs. The problem is reading the file. When I try to download a saved file via a web browser window, I see that the file contents are wrapped with something like the following: ------WebKitFormBoundarye38W9pfG1wiA100l Content-Disposition:

Storing data stream from POST request in GridFS, express, mongoDB, node.js

点点圈 提交于 2019-11-27 07:18:26
I am trying to figure out how I can post an image directly to GridFS without storing it anywhere on the server as a temporary file first. I am using Postman (chrome ext.) to post a file, and I manage to store this post as a file using: req.pipe(fs.createWriteStream('./test.png')); I am also able to store directly to GridFS from a readStream when the readStream is created from a file on the server. (see code) I have the following files, saveFromReq.js which listens for the POST and basically just passes this on to the savePic.js . saveFromReq.js: var express = require('express'); var app =

Storing data stream from POST request in GridFS, express, mongoDB, node.js

北城以北 提交于 2019-11-26 13:07:54
问题 I am trying to figure out how I can post an image directly to GridFS without storing it anywhere on the server as a temporary file first. I am using Postman (chrome ext.) to post a file, and I manage to store this post as a file using: req.pipe(fs.createWriteStream(\'./test.png\')); I am also able to store directly to GridFS from a readStream when the readStream is created from a file on the server. (see code) I have the following files, saveFromReq.js which listens for the POST and basically