Closed bigmeech closed 10 years ago
I'm instatiating the grid like this.
var fs = require("fs"); var gridStream = require("gridfs-stream"); var mongoose = require("./database"); var grid = gridStream(mongoose.connection, mongoose.mongo); exports.getGrid = function(){ return grid; }
here is how i'm using the gridStream
var gridStore = require("../lib/gridStore"); var fs = require("fs"); var grid = gridStore.getGrid(); var file = req.files.productPic; var gridStream = grid.createWriteStream({ filename:file.name, mode:"w", root:"productImages", metadata:file }); fs.createReadStream(file.path).pipe(gridStream); fs.on("end",function(){ res.send("Uploaded"); }); fs.on("error", function(err){ res.json({error:true,message:"Error uploading file",details:err}); })
what am i doing wrong?
I'm instatiating the grid like this.
here is how i'm using the gridStream
what am i doing wrong?