Meteor-files: Can not remove file

Created on 29 May 2019  路  1Comment  路  Source: veliovgroup/Meteor-Files

Using this method

  orbiterFilesRemove(id) {
    return OrbiterFiles.remove({_id: id});
  },

I get an exception:

(node:31887) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded

This is the definition of OrbiterFiles

export const OrbiterFiles = new FilesCollection({
  storagePath: storagePath,
  collectionName: 'orbiter_files',
  allowClientCode: false, // Disallow remove files from Client
  onBeforeUpload(file) {
    // Allow upload files under 10MB, and only in png/jpg/jpeg formats
    if(file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) return true;
    return 'Please upload image (png or jpg), with size equal or less than 10MB';
  },
});

question

Most helpful comment

Found the solution.
The object returned by OrbiterFiles.remove() is not a JSONable object.
Meteor try to return it and is stucked in a infinite loop.
Just remove the return statement, and it is fine....

  orbiterFilesRemove(id) {
    OrbiterFiles.remove({_id: id});
  },

or

  orbiterFilesRemove(id) {
    OrbiterFiles.remove({_id: id});
    return 'whatever';
  },

>All comments

Found the solution.
The object returned by OrbiterFiles.remove() is not a JSONable object.
Meteor try to return it and is stucked in a infinite loop.
Just remove the return statement, and it is fine....

  orbiterFilesRemove(id) {
    OrbiterFiles.remove({_id: id});
  },

or

  orbiterFilesRemove(id) {
    OrbiterFiles.remove({_id: id});
    return 'whatever';
  },
Was this page helpful?
0 / 5 - 0 ratings