meteor-uploads icon indicating copy to clipboard operation
meteor-uploads copied to clipboard

I'm having problems with files that have spaces or _ (underscores) in them.

Open rootedsoftware opened this issue 8 years ago • 2 comments

I was able to use this in my

UploadServer.init({
getFileName: function( fileInfo, formData ) {
      try {
        return fileInfo.name.replace(/[*_\s]/g, '');
      } catch(e) {
        throw new Meteor.Error(500, e);
      }
    });

To return the fixed file name, but the url includes the name with spaces and _ in them still. I'm sure I could use a collection.after to fix this in the collection, but I believe this is a bug.

rootedsoftware avatar Apr 19 '16 17:04 rootedsoftware

For anyone else that might need a temporary solution, here is what I am doing.

Uploads.before.insert(function (userId, doc, fieldNames, modifier) {
  // Remove spaces and underscores from the url
  doc.url = doc.url.replace( /[*_\s]/g, '' );
  return true;
});

rootedsoftware avatar Apr 19 '16 19:04 rootedsoftware

Also having an issue. This should be fixed properly without removing spaces. I need files to remain the same since some files reference each other with relative urls. I can't expect users who upload files to assume all spaces will be removed so their files can reference each other....

msj121 avatar May 06 '16 07:05 msj121