Skip to content

micahalcorn/meteor-google-cloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meteor-google-cloud

Wrapper for Node "gcloud" package


### Authorization

Inspiration (and some text) taken from meteor-slingshot

Generate a private key and convert it to a .pem file using openssl:

openssl pkcs12 -in google-cloud-service-key.p12 -nodes -nocerts > google-cloud-service-key.pem

Setup CORS on the bucket:

gsutil cors set docs/gs-cors.json gs://your-bucket-name

Save this file into the /private directory of your meteor app and add this line to your server-side code:

GoogleCloud = new gcloud({
	projectId: Meteor.settings.private.Google.projectId,
	credentials: {
		client_email: Meteor.settings.private.Google.accessId,
		private_key: Assets.getText('google-cloud-service-key.pem')
	}
});

Note that you will need to place your projectId and accessId in your settings.json nested under private: { Google: { (or change the code above to match your preferred settings).

You can also set your authorization config "per service" if you do not prefer the global configuration. In that case you would use the existing global variable gcloud and simply:

gcloud.storage(/* { your auth object } */);

Use

Now you can do the following:

GoogleCloud.storage().createBucket('/* a unique bucket name */', function (err, res) {
  if (err) {
    console.log(err);
  } else {
    console.log('Success!');
  }
});

... along with all the other things.


This is my second Meteor package, so feel free to let me know how I can improve it or if you run into any issues. :)

About

Wrapper for Node "gcloud" package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published