meteor-uploads
meteor-uploads copied to clipboard
I'm having problems with files that have spaces or _ (underscores) in them.
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.
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;
});
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....