Example on using MeteorUp
December 12, 2016 ยท View on GitHub
Brief
MeteorUp uses Docker, and by default, there is no volume mounted on the server. Therefore, even if storagePath is declared in contructor, files that are being uploaded are still being stored in cache, and on every deploy, all the uploaded files get erased.
Read more on Issue #270 and Issue #290.
To resolve this issue, a volume has to be declared in mup.json.
In this example, images will be stored under folder images, under /images on the server.
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: 0774,
parentDirPermissions: 0774,
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 just like the given demos.