我正在尝试使用edgee:slingshot上传文件,但我有几个错误。我已经按照 github 页面中的描述做了所有事情。这是我在服务器上的设置:
Slingshot.GoogleCloud.directiveDefault.GoogleSecretKey = Assets.getText('google-cloud-service-key.pem');
Slingshot.createDirective("myFileUploads", Slingshot.GoogleCloud, {
bucket: 'dossum-app',
GoogleAccessId: "GOOGXXXX",
GoogleSecretKey: "qZEsLZ/NiXXXXXXXXXXXXUW8NVjSvRb8SgdxXXXXX2",
acl: 'bucket-owner-full-control',
authorize: function() {
if (!this.userId) {
var message = 'Please login before posting file';
throw new Meteor.Error('Login Required', message);
}
return true;
},
key: function(file) {
var user = Meteor.users.findOne(this.userId);
return user.username + '/' + file.name;
}
});
这是cors.json:
[{"origin": ["http://localhost:3000", "http://qnekt.zehinz.com"], "responseHeader": ["Origin", "Accept", "X-Requested-With", "Authorization", "Content-Type", "Content-Length", "Accept-Encoding", "X-CSRF-Token"], "method": ["GET", "HEAD", "DELETE", "PUT", "POST", "HEAD"], "maxAgeSeconds": 3600}]
如果我使用上述配置运行,我会收到此错误,但没有任何详细信息:{error: 500, reason: "Internal server error"....
我尝试评论此行: //GoogleSecretKey:"qZEsLZ/NiEkXo641XHIUW8NVjSvRb8SgdxIyYcV2"
这次我收到此错误:
{error: "Forbidden - 403", reason: "Failed to upload file to cloud storage", details: undefined ...
谁能指导我?
如果我使用.pem文件而不是GoogleSecretKey ,我应该在哪里获得GoogleAccessId?
用于文件上传和公共阅读的 cors.json 文件应该是什么?