2015-05-21 7 views
0

Я пытаюсь загрузить файлы с помощью edgee:slingshot, но у меня есть несколько ошибок. Я сделал все, как описано на странице github. Это мои настройки на сервере:Загрузите файл Meteor slingshot на сервер Google Cloud Storage.

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 ... 

Может кто-нибудь, пожалуйста, руководство меня?

  1. Где я должен получить GoogleAccessId, если я использую .pem файл вместо GoogleSecretKey?

  2. Каким должен быть файл cors.json для загрузки файлов и публичного чтения?

+1

Существует неизданная ветка рогатки с более подробными документами для облачного хранилища Google, возможно, это поможет: https://github.com/CulturalMe/meteor-slingshot/tree/subpackages/services/edgee:slingshot- google-cloud –

+0

@d_inevitable да, это помогло. проблема была в GoogleSecretKey – torayeff

+0

Если вы ее решили, ответьте на свой вопрос, чтобы помочь тем, у кого есть аналогичная проблема. –

ответ

5

У меня были проблемы с edgee:slingshot и Google Cloud Storage. Но эти настройки теперь работают на меня:

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

Slingshot.createDirective('avatarUploader', Slingshot.GoogleCloud, { 
    bucket: 'my_bucket', 
    GoogleAccessId: '[email protected]', 
    acl: 'public-read', 
    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); 
     var ext = file.type.split('/')[1]; 
     return user.username + '/' + randomString(20) + '.' + ext; 
    } 
}); 

//CORS settings 
[ 
    { 
    "origin": ["*"], 
    "responseHeader": ["*"], 
    "method": ["GET", "POST", "PUT", "HEAD"], 
    "maxAgeSeconds": 3000 
    } 
] 

Подробнее см. here.

Смежные вопросы