I am trying to build an application that will access files in my google cloud storage while the bucket is private. The docs arent clear on what to do to enable access of the bucket from a server. I have the json file which they provide. I plan on using to expose the files on the bucket using nodejs but I'm not sure how to authorize requests to the bucket. I am using axios by the way. Do i create an API key or use a key as a query string? Some help would be appreciated!
You want Google Cloud's Node.JS library: https://googlecloudplatform.github.io/google-cloud-node/#/
Here's an example of using it to access an object in GCS:
var config = {
projectId: 'grape-spaceship-123',
keyFilename: '/path/to/keyfile.json'
};
var storage = require('@google-cloud/storage')(config);
var bucket = gcs.bucket('my-existing-bucket');
var remoteReadStream = bucket.file('giraffe.jpg').createReadStream();
remoteReadStream.pipe(someLocalWriteStream);
There are several other examples on the GitHub page: https://github.com/GoogleCloudPlatform/google-cloud-node#preview-1
As well as extensive documentation here: https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/0.56.0/storage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With