Meteor-CollectionFS createReadStream() error: FS.Utility.safeStream requires a NodeJS Stream

Meteor-CollectionFS createReadStream() error: FS.Utility.safeStream requires a NodeJS Stream

The repo 已存档,当我尝试编写迁移工具时,我发现无法获取使用 Meteor-CollectionFS.

存储的文件

API 说我可以使用 fs.createReadStream() 来获取文件,但是当我在 运行 数据库上执行此操作时,我收到此错误:

Error: FS.Utility.safeStream requires a NodeJS Stream
    at Object.FS.Utility.safeStream (packages/cfs_base-package.js:418:11)
    at Object.self.adapter.createReadStream (packages/cfs_storage-adapter.js:114:23)
    at FS.File.createReadStream (packages/cfs_file.js:833:30)
    at CFSAttachments.find.forEach.file (server/migrations.js:1049:24)
    at SynchronousCursor.forEach (packages/mongo/mongo_driver.js:1107:16)
    at Cursor.(anonymous function) [as forEach] (packages/mongo/mongo_driver.js:887:44)
    at Object.Migrations.add [as migrationCallback] (server/migrations.js:1047:24)
    at packages/idmontie_migrations.js:238:17
    at Function.time (/programs/server/profile.js:273:30)
    at /programs/server/boot.js:412:15
    at /programs/server/boot.js:462:7
    at Function.run (/programs/server/profile.js:280:14)
    at /programs/server/boot.js:460:13
** HTTP-BRIDGE: App server exited with status code: 1

我完全不知道这是怎么发生的。我正在尝试在沙尘暴系统中迁移 wekan grain。任何人都可以提供帮助,或者给我一个解决方法来提取存储在 mongoDB 中的文件吗?谢谢。

正如@Jankapunkt 提到的,我可以像这样从 MongoDB gridFS 系统中检索数据:

  import { MongoInternals } from 'meteor/mongo';

  const http = require('http');
  const fs = require('fs');
  CFSAttachments.find().forEach(file => {
    const bucket = new MongoInternals.NpmModule.GridFSBucket(
       MongoInternals.defaultRemoteCollectionDriver().mongo.db, 
       {bucketName: 'cfs_gridfs.attachments'}
    );
    const gfsId = new MongoInternals.NpmModule.ObjectID(file.copies.attachments.key);
    const reader = bucket.openDownloadStream(gfsId);
    const path = `/var/attachments/${file.name()}`;
    const fd = fs.createWriteStream(path);
    reader.pipe(fd);
    Attachments.addFile(path, opts, (err, fileRef) => {
      if (err) {
        console.log('error when migrating ', fileName, err);
      } else {
        file.remove();
      }
    });
  });