Skip to content

MeteorUp (MUP) Usage

dr.dimitru edited this page Dec 9, 2017 · 3 revisions

Brief

MeteorUp (MUP) uses Docker, and by default, there is no volume mounted on the server. Therefore, even if storagePath is declared in constructor, files that are being uploaded are still being stored in cache, and on every deploy, all the uploaded files get erased.

Read more at Issue #270 and Issue #290.

To solve this issue, a volume has to be declared in project-root/mup.json. In this example, images will be stored at /images directory.

mup.json example:

module.exports = {
  servers: {
    one: {
      host: 'myapp',
      username: 'root',
      // pem:
      // password:
      // or leave blank for authenticate from ssh-agent
    }
  },

  meteor: {
    name: 'myapp',
    path: '../app',
    volumes: {
      '/images':'/images'
    },
    servers: {
      one: {}
    },
    buildOptions: {
      serverOnly: true,
    },
    env: {
      ROOT_URL: 'http://myapp.com',
      MONGO_URL: 'mongodb://localhost/meteor'
    },

    //dockerImage: 'kadirahq/meteord',
    deployCheckWaitTime: 60
  },

  mongo: {
    oplog: true,
    port: 27017,
    servers: {
      one: {},
    },
  },
};

Images constructor example

Images = new FilesCollection({
  debug: true,
  storagePath: '/images',
  permissions: 0o774,
  parentDirPermissions: 0o774,
  collectionName: 'Images',
  allowClientCode: false, // Disallow remove files from Client
  onBeforeUpload: function(file) {
    // Allow upload files under 10MB, and only in png/jpg/jpeg formats
    if (file.size <= 1024*1024*10 && /png|jpg|jpeg/i.test(file.extension)) {
      return true;
    } else {
       return 'Please upload image, with size equal or less than 10MB';
    }
  }
});

Now, files will be uploaded to /images on server, and can be accessed like in demos.

Clone this wiki locally