是否可以在不在 meteor 中创建用户帐户的情况下使用 edgee:slingshot file uploader 为 meteor 上传文件?

Is it possible to upload files using edgee:slingshot file uploader for meteor without creating a user account in meteor?

我正在尝试创建一个简单的评论表单,访问者可以在其中创建评论。评论将是:comment = { name: "string", body: "string", image: "string" }

我希望任何人都能够创建评论和上传图像,而无需创建用户帐户。动机是这是为了纪念一位去世的朋友。访问者应该能够上传记忆图片而无需创建帐户。

当我尝试将文件上传到 AWS 时,出现以下错误:

TypeError: Meteor.userId is not a function


userId: Meteor.userId()                                                 // 70

我在那行设置断点,发现第70行Meteor.userId()未定义。

validate: function(file) {                                                  // 68
      var context = {                                                           // 69
        userId: Meteor.userId()                                                 // 70
      };                                                                    

    // 71
      try {                                                                     // 72
        var validators = Slingshot.Validators,                                  // 73
            restrictions = Slingshot.getRestrictions(directive);                // 74
                                                                                // 75
        validators.checkAll(context, file, metaData, restrictions) && null;     // 76
      } catch(error) {                                                          // 77
        return error;                                                           // 78
      }                                                                         // 79
    },      

有什么方法可以禁止 Meteor.userId() 通过 API 干净地上传带有 slingshot 的文件吗?或者只是让人们注册并登录,以便 Meteor.userId( ) 可以使用一些东西?

您不需要用户 ID 即可上传。但是当您使用验证时,您必须添加帐户包。您需要至少添加一个登录提供程序包:accounts-password 或 ... .

目前似乎是一个错误。

它是弹弓中的一个 bug,但也许您可以解决它直到它被修复?

if (!Meteor.userId)
  Meteor.userId = function () {};

请注意,此声明必须在使用 slingshot 之前出现,如果您的应用程序的任何部分依赖 Meteor.userId 未定义为未启用帐户的标志,那么此更改可能会破坏您的应用程序。