Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 部署后,应用程序无法将文件上载到S3,并给出意外标记<;错误_Meteor_Meteor Slingshot - Fatal编程技术网

Meteor 部署后,应用程序无法将文件上载到S3,并给出意外标记<;错误

Meteor 部署后,应用程序无法将文件上载到S3,并给出意外标记<;错误,meteor,meteor-slingshot,Meteor,Meteor Slingshot,我试图将文件上传到我的S3 bucket bay,从EC2实例获取凭据(应用程序托管在EC2中)。以下是指令: var credentials = new AWS.EC2MetadataCredentials(); var updateCredentials = Meteor.wrapAsync(credentials.get, credentials); Slingshot.createDirective("achievementPhotoUpload", Slingshot.S3Sto

我试图将文件上传到我的S3 bucket bay,从EC2实例获取凭据(应用程序托管在EC2中)。以下是指令:

var credentials = new AWS.EC2MetadataCredentials();

var updateCredentials = Meteor.wrapAsync(credentials.get, credentials);


Slingshot.createDirective("achievementPhotoUpload", Slingshot.S3Storage.TempCredentials, {
  bucket: "...",

  acl: "public-read",

  region: "...",

  temporaryCredentials: function () {
    if (credentials.needsRefresh()) {
      updateCredentials();
    }

    return {
      AccessKeyId: credentials.accessKeyId,
      SecretAccessKey: credentials.secretAccessKey,
      SessionToken: credentials.sessionToken
    };
  },

  authorize: function () {
    //Deny uploads if user is not logged in.
    if (!this.userId) {
      var message = "Please login before posting files";
      throw new Meteor.Error("Login Required", message);
    }

    return true;
  },

  key: function (file) {
    return "achievement-photos/" + file.name;
  }
});
但它不会上传。当我检查日志时,我发现:

Session terminated, terminating shell... ...terminated.
`Meteor.addCollectionExtension` is deprecated, please use `CollectionExtensions.addExtension`
Exception while invoking method 'slingshot/uploadRequest' SyntaxError: Unexpected token <
    at Object.Future.wait (/opt/kwabackend/app/programs/server/node_modules/fibers/future.js:420:15)
    at packages/meteor/helpers.js:119:1
    at Object.temporaryCredentials (server/uploaders/AchievementPhotosAccess.js:21:7)
    at Object.Slingshot.S3Storage.TempCredentials._.defaults.applySignature (packages/edgee_slingshot/packages/edgee_slingshot.js:776:$
    at Object.Slingshot.S3Storage.upload (packages/edgee_slingshot/packages/edgee_slingshot.js:696:1)
    at [object Object]._.extend.getInstructions (packages/edgee_slingshot/packages/edgee_slingshot.js:343:1)
    at [object Object].Meteor.methods.slingshot/uploadRequest (packages/edgee_slingshot/packages/edgee_slingshot.js:425:1)
    at packages/check/match.js:103:1
    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
    at Object.Match._failIfArgumentsAreNotAllChecked (packages/check/match.js:102:1)
    - - - - -
    at Object.parse (native)
    at /opt/kwabackend/app/programs/server/npm/peerlibrary_aws-sdk/node_modules/aws-sdk/lib/metadata_service.js:115:38
    at IncomingMessage.<anonymous> (/opt/kwabackend/app/programs/server/npm/peerlibrary_aws-sdk/node_modules/aws-sdk/lib/metadata_serv$
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickDomainCallback (node.js:492:13)

你能给我们看看这两行代码吗:at packages/meteor/helpers.js:119:1 at Object.temporaryCredentials(server/uploaders/Achieventphotosaccess.js:21:7)@StephenWoods Hi,我不知道如何找到helpers.js,但是
Achieventphotosaccess.js
的第21行是
UpdateRadentials()
credentials.get中有什么?@StephenWoods看起来像
EC2MetadataCredentials
中的方法AWS sdk中的方法。是否可能是AWS中的bucket策略不正确?
updateCredentials();