- Github – https://github.com/shaneosullivan/gcloud-storage-json-upload
- NPM – https://www.npmjs.com/package/gcloud-storage-json-upload
Authentication to the Google Cloud, as well as uploading to it, is quite simple when using Google’s Cloud services SDK. A big downside of using these with NodeJS is that they bring 80MB of dependencies, which if you are packaging your application for distribution is a little bit crazy.
Authentication to Google Cloud’s HTTP JSON API (link) can be a bit tricky in Node, as you need to construct your own authentication token, cryptographically sign it, and make sure you’re using all the right data, serialized just so. I’ve written a small tool, linked above, to do this authentication for you.
Uploading to Google Cloud’s Storage uses the authentication token, and takes a few other parameters that are easy to get wrong. The tool also does the upload of a simple file to a Cloud Storage bucket that you have the private key for a service account.
Using the code is simple (see the README)
Please let me know if you’d like any additions or find bugs in the issues tracker.