Meteor - Using FS returns TypeError: Cannot read property 'Collection' of undefined


I am using Meteor 1.6 and AngularJS (Angular 1) and am having issues in my /server/main.js file. I am trying to do an import like this:

import { FS } from 'meteor/cfs:filesystem';

So Meteor is able to resolve it just fine, but the problem is, it is undefined somehow. So when I do this:

Images = new FS.Collection("images", {

I get the error mentioned above. I have been trying to find answers online and I’ve been referencing the Meteor Collection FS Documentation but haven’t been able to resolve what I’m doing wrong with my import. Can anyone direct me how to fix this?


The cfs packages do not have api.export() directives in their package.js files. That means they won’t import. (Actually, the import destroys the global FS object).

So, assuming you have done at least meteor add cfs:standard-packages cfs:filesystem cfs:collection, you should be able to do:

Images = new FS.Collection("images", {...

With no import statement

This is basically old-school Meteor, with the FS object being put into the global space automatically.

I should add that these packages are fundamentally deprecated and not actively maintained.


Okay, that’s good to know… so is that why I can’t upload images on my server? I fixed it (with no import) and that’s working now, but I’m getting strange errors when trying to upload on the server. Should I be using something else if this is deprecated?


It’s supposedly not deprecated anymore, but it’s not very actively maintained.

cfs:gridfs stopped working when I upgraded to 1.6 though, and I had to fork it to fix it, and they still haven’t accepted my pull request.

I think ostrio:files is the most popular one these days?


Okay, cool, I’ll look into that. So just to clarify, the ostrio:files package should help w/saving files to the filesystem, correct?I’m pretty sure my angular/front-end uploading side of things is good to go. --Edit - nevermind, I looked at it and that’s what it is. Trying it now. Thanks!


@herteby, I got the ostrio:files thing working so my images are uploading to the server (as far as I know) and the DB has a reference to them, but I don’t know how to actually serve them up. For example, I uploaded an image this morning. The DB contains the original name, and the file path that it exists at now:


The problem is, when I put that into the url, it just returns my app’s homepage. I tried changing the upload directory to be ‘/images/’ but still have the same issue. I can’t seem to find a clear answer in Meteor’s documentation on how to open up a path for images, aside from including them when you build the package, but that defeats the purpose of user-input.


@froggin there is many ways to get “downloadable” link: