1

I have successfully uploaded a text file into a FS collection store. Now I want to modify the content of that text file or extract some information.

I can get the file object with:

var fileObj = myFSCollection.findOne({});

From what I have read, this is just a pointer to the file and not the file itself. How do I grab the text inside the text file so that I can modify it?

John McNeill
  • 143
  • 1
  • 12

1 Answers1

2

You can get the file itself with fileObj.url(). You cannot, however, update the file that CollectionFS has stored for you. You have to remove the original and insert a new one.

To download the file:

HTTP.get(fileObj.url(),function(err,result){
  if ( !err ){
    var content = result.content;
  }
});
Michel Floyd
  • 18,793
  • 4
  • 24
  • 39
  • console.log(fileObj.url()) gives me a path to the the text file. How do I read that text file and store the text in a variable so that I can see it? – John McNeill Mar 05 '16 at 16:55