I'm following the GridFS docs. The createObjectId and createBucket functions use MongoInternals. But MongoInternals is not available on the client. But the FilesCollection is created on both server and client. And hence createOnAfterUpload etc. are executed on the client.
Did this ever work? Or is the GridFS example broken? I'm new to Meteor and I find the mixing of Meteor.isServer and Meteor.isClient weird. Am I supposed to create a separate FilesCollection on the client but omit onAfterUpload etc?
I'm now doing this, which is ugli
const bucket = Meteor.isServer ? createBucket('attachments') : null;
export const Attachments = new FilesCollection({
collectionName: 'attachments',
allowClientCode: false,
onAfterUpload: Meteor.isServer ? createOnAfterUpload(bucket) : undefined,
interceptDownload: Meteor.isServer ? createInterceptDownload(bucket) : undefined,
onAfterRemove: Meteor.isServer ? createOnAfterRemove(bucket) : undefined,
});
I'm following the GridFS docs. The
createObjectIdandcreateBucketfunctions useMongoInternals. ButMongoInternalsis not available on the client. But theFilesCollectionis created on both server and client. And hencecreateOnAfterUploadetc. are executed on the client.Did this ever work? Or is the GridFS example broken? I'm new to Meteor and I find the mixing of
Meteor.isServerandMeteor.isClientweird. Am I supposed to create a separateFilesCollectionon the client but omitonAfterUploadetc?I'm now doing this, which is ugli