Friday 14 August 2015

Uploading image with userid, so that 1 can browse photogallery

iam writing this article and also uploading a project so that you can see how it works

i was stuck with this problem
in my project, i allow users to upload multiple images, and they are stored using cfs:filesystem
in 3 types as icon, as thumbnail and actual image

thumbnail images are required so that they show up in browse members and on the profile of the user
and when the user clicks on the members profile he is taken to that particular users photogallery

in order to do that you just need to modify file collection, so that it stores userid in cfs.images.filerecord collection

and the code is
'Template.myForm.events({
    'change .myFileInput': function(event, template) {
        FS.Utility.eachFile(event, function(file) {

var newfile=new FS.File(file)
newfile.userid=Meteor.userId();

            Images.insert(file, function (err, fileObj) {
                //If !err, we have inserted new doc with ID fileObj._id, and                //kicked off the data upload using HTTP            });
        });
    }
});'


the code marked in the red, is all that you got to do to insert userid in cfs.images.filrecord collection
so that you can link those images to a particular user

you can download source code from here

http://www.amincode.com/codes/viewcode?codeid=55cd9712cb64a32fe042636b




Monday 10 August 2015

Meteor: unexpected mongo exit code 100

After you copy of your meteor project folder then this happens

Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start mongod

MongoDB had an unspecified uncaught exception.
Check to make sure that MongoDB is able to write to its database directory.

when i got this error i got scared, since almost whole project has been built and now this error, which doesn't seems to go

iam talking about Linux ubuntu

Solution is simple
you got to erase
rm .meteor/local/db/mongod.lock
from the project folder

if you are on linux ubuntu, you can check the exact file name by doing "ls" command

login as root again
and then type meteor, it shall work

do not do meteor reset, it will erase your database

Meteor Data not displaying

this is common mistake you will have when building meteor app, when you are new

fix is that you need to subscribe to that collection
you have to mention that in .js file for that template

Meteor.subscribe("yourcollection");