Hi,
I´m building an app in angular (MEAN stack). I´m storing images in mongoDB,
using GridFS. The images are given a custom ID, to identify, to which user
they belong. Saving the images seems, to work. I can see fs.chunks and
fs.files data entries in my DB.
I cant manage to get the images saved in MongoDB and display them in my app.
What am I doing wrong?
*GridFS POST and GET*
conn.once('open', function(){
> console.log('Grid Stream open')
> var gfs = Grid (conn.db);
> app.post('/uploads/', function(req, res){
> req.pipe(gfs.createWriteStream({
> metadata:{
> "objectId" : req.body.project_id
> },
> }));
> res.send("Success");
> });
> app.get('/uploads/media/:projectId', function(req, res){
> var readstream = gfs.createReadStream({
> metadata: {
> "objectId" : req.params.projectId
> }
> });
> readstream.on("data", function (chunk){
> buffer +=chunk;
> });
> readstream.on("end", function(){
> console.log("contents of file:\n\n", buffer);
> });
> });
> });
*GET Angular Controller*
> $http.get('/uploads/media/'+$scope.projectId).success(function(data){
> $scope.media = data;
*Displaying it in my app *
> <img ng-src="{{media}}"/>
The GET request from angular seems to work, but I cant fetch any data.
Thank you!
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.