Uploading images on galaxy makes my site crash


#1

Hi !

Trough a form i want the users to upoad images like choosing an avatar and posting items their own images.
I’m using a galaxy server. Each time a user try to upload an image i get this error on my logs

2016-08-16 11:01:48-04:00/app/bundle/programs/server/app/app.js:987
bc87
2016-08-16 11:01:48-04:00 throw new Meteor.Error(500, ‘Failed to save file.’, err); // 47
bc87
2016-08-16 11:01:48-04:00 ^
bc87
2016-08-16 11:01:48-04:00Error: Failed to save file. [500]
bc87
2016-08-16 11:01:48-04:00 at server/main.js:47:18
bc87
2016-08-16 11:01:48-04:00 at fs.js:1134:7
bc87
2016-08-16 11:01:48-04:00 at FSReqWrap.oncomplete (fs.js:82:15)
bc87
2016-08-16 11:01:48-04:00Application exited with code: 1 signal: null
bc87
2016-08-16 11:01:48-04:00Application process closed with code: 1 signal: null
bc87
2016-08-16 11:01:55-04:00The container has crashed. A new container will be started to replace it.
j8kh
2016-08-16 11:02:20-04:00Application process starting, version: 1 on apprunner (embedded)

The site crashes for 10 minutes and then start working again.
And here is the code that handles the file upload, i’m not using any packages:

saveFile: function(blob, name, path, encoding) {
  var path = cleanPath(path), fs = Npm.require('fs'),
      name = name, encoding = encoding || 'binary',
    chroot = Meteor.chroot || '../../../../../public/uploads';
      path = chroot + (path ? '/' + path + '/' : '/');
  
  fs.writeFile(path + name, blob, encoding, function(err) { // THE ERROR HAPPENS HERE
    if (err) {
      throw (new Meteor.Error(500, 'Failed to save file.', err));
    } else {
      console.log('The file ' + name + ' (' + encoding + ') was saved to ' + path);
    }
  });

I’ve read that Meteor is not recommended for storing files. But does it means I cannot transfer any files or images ?
Thanks !


#2

Take a look at the File storage section of the Galaxy Docs. Quoting the relevant bits:

Galaxy provides temporary file storage for application containers to use. Galaxy does not provide persistent file storage for application containers to use.

Application containers are given read/write access to the /tmp directory and /tmp sub-directories. Application containers do not have read/write access to the /root directory or to the $HOME directory.