[solved] GoogleCloud Storage access


#1

I have used the great plugin edgee:slingshot to upload files to GoogleCloud Storage. The files are not public accessible (and should not be). But how can I load the images now in Meteor?

I would like to load them directly from the client, so that I don’t loop the traffic through the server.

I have not found any good solution yet and would be thankful for a hint :slight_smile: Did anyone solve this problem already?


#2

Maybe this can help:

https://cloud.google.com/storage/docs/access-control#Signed-URLs


#3

Thank you @maartenbusstra!

I have managed to solve the problem the following way:

  1. When the form with the file input is submitted, I use the great plugin “Slingshot” to upload the file to Google Cloud Storage
  2. To display the file I created a template that contains an image with a helper that loads the src attribute from an (reactive) instance variable.
  3. Once the template is onCreated, I call a Meteor method that uses the Google Cloud SDK to request a signed URL with Meteor.wrapAsync

#4

Hi

I see you have successfully managed to use Slingshot with Google Cloud Storage.

Could you help me ?

I don’t know what to fill in:
GoogleAccessId:
GoogleSecretKey:
bucket:
acl: “public-read”,

I have a .pem file, but can’t figure out how they fit with the attributes above.


#5

@durhei

You can follow the instructions here:

https://atmospherejs.com/edgee/slingshot

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


#6

Thank you. I had checked that one out, but was still missing AccessID.

I finally found: https://github.com/CulturalMe/meteor-slingshot/tree/subpackages/services/edgee:slingshot-google-cloud

Which clearly spells it out:

Slingshot.GoogleCloud.directiveDefault.GoogleAccessId = “Enter your access id (it looks like an email address)”;
Slingshot.GoogleCloud.directiveDefault.GoogleSecretKey = Assets.getText(‘google-cloud-service-key.pem’);

My other issue was that I didn’t was to save the .pem file in private, as the code would be public using github to push the code to Heroku. My solution to this was to save AccessId and SecretKey as environment variables and use process.env.ENVIRONMENT_VARIABLE_NAME to get the values, like:
Slingshot.GoogleCloud.directiveDefault.GoogleAccessId = process.env.GOOGLE_ACCESS_ID;
Slingshot.GoogleCloud.directiveDefault.GoogleSecretKey = process.env.GOOGLE_SECRET_KEY;


#7

i have the same problem! you can solve this?