尝试使用弹弓包从Meteor上传时出现500错误

时间:2015-02-18 21:54:03

标签: javascript meteor google-cloud-storage meteor-slingshot

我正在使用以下Meteor Package

https://atmospherejs.com/edgee/slingshot

我在服务器端有一个javascript文件,看起来像这样

Slingshot.GoogleCloud.directiveDefault.GoogleSecretKey = Assets.getText('google-cloud-service-key.pem');


Slingshot.createDirective("myFileUploads", Slingshot.GoogleCloud, {
  bucket: "enwave",
  GoogleAccessId: "randomID",

 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) {

   //Store file into a directory by the user's username.
   var user = Meteor.users.findOne(this.userId);
   return user.username + "/" + file.name;
 }
});

我在客户端有这个

'change #fileUpload':function(event, template){
      //evt.preventDefault();
      var file = event.currentTarget.files[0];
      console.log(file);

      var uploader = new Slingshot.Upload("myFileUploads");
      uploader.send(document.getElementById('fileUpload').files[0], function (error, downloadUrl) {
      Meteor.users.update(Meteor.userId(), {$push: {"profile.files": downloadUrl}


      });

      });

    }

我在我的lib文件夹中有这个

Slingshot.fileRestrictions("myFileUploads", {
  allowedFileTypes: ["image/png", "image/jpeg", "image/gif"],
  maxSize: 10 * 1024 * 1024 // 10 MB (use null for unlimited)
});

并在/ private文件夹中我有一个google-cloud-service-key.pem文件,我是在从谷歌云下载后转换的。

在文件上传输入中选择图像时出现此错误

 POST https://enwave.storage.googleapis.com/ 500 (OK)
debug.js:41 update failed: Access denied

我一定是做错了,谷歌说谷歌云中的500错误是一个内部服务器错误,但我一定做错了,我高度怀疑它是谷歌结束。如果可能的话,我也会测试localhost。

在预先感谢您的帮助。

在控制台中记录错误后,这就是我得到的

http://i.stack.imgur.com/pffI4.png

这是XML响应

<?xml version='1.0' encoding='UTF-8'?>InternalErrorWe encountered an internal error. Please try again. ABCemsqA/49FPwB5u877Jt1vyodMFYvQo+Nxba9L+54t4n31W5StGcfiL1/DfhrzuGEfhi63U6j3 5WYQxoYPL5T9xNaFkuX9Hg...

这是标题返回的内容

Remote Address:74.125.25.132:443
Request URL:https://enwave.storage.googleapis.com/
Request Method:POST
Status Code:500 OK
Request Headers
:authority:enwave.storage.googleapis.com
:method:POST
:path:/
:scheme:https
accept:*/*
accept-encoding:gzip, deflate
accept-language:en-US,en;q=0.8
content-length:59584
content-type:multipart/form-data; boundary=----WebKitFormBoundaryjW0KMAtnvqnxsY7u
origin:http://localhost:3000
referer:http://localhost:3000/submit
user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36
x-client-data:CI62yQEIpLbJAQiptskBCMS2yQEI6ojKAQieksoBGKuJygE=
Request Payload
------WebKitFormBoundaryjW0KMAtnvqnxsY7u
Content-Disposition: form-data; name="key"

minimize.jpeg
------WebKitFormBoundaryjW0KMAtnvqnxsY7u
Content-Disposition: form-data; name="bucket"

enwave
------WebKitFormBoundaryjW0KMAtnvqnxsY7u
Content-Disposition: form-data; name="Content-Type"

image/jpeg
------WebKitFormBoundaryjW0KMAtnvqnxsY7u
Content-Disposition: form-data; name="Content-Disposition"

inline; filename="minimize.jpeg"
------WebKitFormBoundaryjW0KMAtnvqnxsY7u
Content-Disposition: form-data; name="GoogleAccessId"

00b4903a977a9b1f9ad3c9f1f3785afdc1af228104554ee6fce967a7899eb208
------WebKitFormBoundaryjW0KMAtnvqnxsY7u
Content-Disposition: form-data; name="policy"

eyJjb25kaXRpb25zIjpbWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCw1ODEyMl0seyJrZXkiOiJtaW5pbWl6ZS5qcGVnIn0seyJidWNrZXQiOiJlbndhdmUifSx7IkNvbnRlbnQtVHlwZSI6ImltYWdlL2pwZWcifSx7IkNvbnRlbnQtRGlzcG9zaXRpb24iOiJpbmxpbmU7IGZpbGVuYW1lPVwibWluaW1pemUuanBlZ1wiIn1dLCJleHBpcmF0aW9uIjoiMjAxNS0wMi0xOVQxNzoxNzoxMy43MThaIn0=
------WebKitFormBoundaryjW0KMAtnvqnxsY7u
Content-Disposition: form-data; name="signature"

QmiNNCDxvbYvZ8X27dCsj4OjvSj4zzIcb3pWuo6qP+10mo9TkaUTgc1Su8EbAW04OtZtZr2Uiohf8S5bIiEqbUBQS8bknFszysTvTQSSOD4DsZM6dNP6iZ5Ukd9Qboc3aoAH5WOJCKxRnxJVdOM6NTr4W5V5SSXtgooHKWrOTIA=
------WebKitFormBoundaryjW0KMAtnvqnxsY7u
Content-Disposition: form-data; name="file"; filename="minimize.jpeg"
Content-Type: image/jpeg


------WebKitFormBoundaryjW0KMAtnvqnxsY7u--
Response Headers
access-control-allow-origin:*
access-control-expose-headers:Content-Length, Content-Type, Date, Server, Transfer-Encoding
alternate-protocol:443:quic,p=0.08
content-length:5196
content-type:application/xml; charset=UTF-8
date:Thu, 19 Feb 2015 17:12:14 GMT
server:UploadServer ("Built on Feb 9 2015 19:54:00 (1423540440)")
status:500

0 个答案:

没有答案