Closed Gobliins closed 11 months ago
Hey,
currently my flow is like this:
When someone uploads a file it's first saved as a file on the filesystem and later after upload, the file is moved into GridFS. Similar to https://github.com/veliovgroup/Meteor-Files/wiki/GridFS-Integration
My (approximately) Code:
// GridFS Bucket create createBucket = (bucketName) => { const options = bucketName ? { bucketName } : void 0; return new MongoInternals.NpmModule.GridFSBucket( MongoInternals.defaultRemoteCollectionDriver().mongo.db, options, ); }; export const Files = new FilesCollection({ .... // move uploaded File from FS to GridFS onAfterUpload(fileObj) { const readStream = fs.createReadStream(filepath); // FS Read const writeStream = this.gridFsBucket.openUploadStream(filepath); // GridFS Write readStream.pipe(writeStream) ... // unlink from FS }, ...
So when adding Files via the Files.load() or Files.insert() methods, is it possible to skip the Filesystem and upload / load / add files, directly into GridFs?
Regards
@Gobliins I understand your frustration but there's no way to skip local file system as intermediate point
@dr-dimitru No worries, just wanted to know :)
Hey,
currently my flow is like this:
When someone uploads a file it's first saved as a file on the filesystem and later after upload, the file is moved into GridFS. Similar to https://github.com/veliovgroup/Meteor-Files/wiki/GridFS-Integration
My (approximately) Code:
So when adding Files via the Files.load() or Files.insert() methods, is it possible to skip the Filesystem and upload / load / add files, directly into GridFs?
Regards