1

Possible duplicate: Meteor collectionfs insert server side

I have multiple image collections using GridFS to store files. If I use "Images" as name for the collection everything works fine, but as soon as I change the name I'm getting GET http://localhost:3000/cfs/files/PlayerImages/zo4Z7rnYLb32MLYkM/taylor.jpg 403 (Forbidden)

(And for example, this one does work: http://localhost:3000/cfs/files/Images/7j9XAEebGctuivGhz/see-more.png)

This is how I defined my collections:

function createImageCollection(name,transform){
  var collectionName = name + 's';
  var storeName = name + 'Store';
  var options = {
    filter: {
      allow: {
        contentTypes: ['image/*'],
        extensions: ['png', 'PNG', 'jpg', 'JPG', 'jpeg', 'JPEG']
      }
    }
  };

  if (Meteor.isServer) {
    storeOptions = {
      path: process.env.PWD + "/public"
    };
    // only add the transform when graphicsmagick is available
    if(gm.isAvailable && typeof transform === 'function'){
      storeOptions.transformWrite = transform;
    }
    options.stores = [new FS.Store.GridFS(storeName,storeOptions)];
  } else {
    options.stores = [new FS.Store.GridFS(storeName)];
  }
  return new FS.Collection(collectionName,options);
}

// and finally create them
// THIS FIRST ONE WORKS JUST FINE
Images = createImageCollection('Image',imageResizeTimeline); // default resize is timeline, nothing bigger then that?
BackgroundImages = createImageCollection('BackgroundImage',imageResizeBackground);
PlayerImages = createImageCollection('PlayerImage',imageResizePlayer);
LogoImages = createImageCollection('LogoImage',imageResizeLogo);

And I also added allow/deny rules for each collection:

var ImagePermissions = {
    insert: function () {
        return true;
    },
    update: function () {
        return true;
    },
    download: function () {
        return true;
    },
    remove: function () {
        return false;
    },
    fetch: null
};
Images.allow(ImagePermissions);
PlayerImages.allow(ImagePermissions);
BackgroundImages.allow(ImagePermissions);
LogoImages.allow(ImagePermissions);

On a sidenote, I am using autoform to generate forms, but I don't think the problem is located in there because "Images" works.

Must I add this path to some "routing" or "config" files? Maybe "Images" is added by default? (This project is set-up by someone else, but I don't think I missed anything he did.)

Community
  • 1
  • 1
robbe clerckx
  • 415
  • 5
  • 16
  • Just curious... what are the permissions of the folders under your /public folder. – Lucas Blancas Sep 14 '15 at 20:15
  • Permissions of the public folder were "read/write" for me and read only for everyone else, I now put the permission to read/write for everyone, but to no avail. (I'm working locally on mac osx yosemite) – robbe clerckx Sep 15 '15 at 06:42
  • Were the permissions for your image folders in the public folder the same? Assume that you meant that, but you didn't say it explicitly so I thought I'd ask – Lucas Blancas Sep 16 '15 at 17:38
  • Yes, they were. But, if I got this correctly, the upload system just uses the "public" folder to write temp files and then writes it as a blob to the database. So the folder permission should not really make a difference when uploading to a different collection, I guess. – robbe clerckx Sep 17 '15 at 06:41

0 Answers0