Search code examples
angularjsmeteorangular-meteorcollectionfs

Get custom path url from collectionFS using filesystem


I'm trying to get the url for files that I upload using collectionFS.

Images.insert(file, function (err, fileObj) {
  if (err) {
    console.log(err);
  } else {
    console.log('success', fileObj);
    setTimeout(function () {
      console.log('url', fileObj.url());
    }, 2000);
  }
});

Currently fileObj.url() returns cfs/files/images/.... but I have a custom path like this:

Images = new FS.Collection("images", {
  stores: [new FS.Store.FileSystem("images", {path: '/home/user/imagesupload'})]
});

How can I get this path when I upload the images?


Solution

  • The path you are setting is the path on your servers local filesystem not the url you want to access it by from the outside world, if you want to use a custom url prefix and not the standard cfs one you need to use the setbaseurl command: FS.HTTP.setBaseUrl('/home/user/imagesupload');