Posts

Showing posts from May, 2016

Upload file to Google Storage from memory with Node.js gcloud library

These days was interacting with the Google Cloud Storage (GCS) with the gcloud nodejs library(version 0.31.0) and was surprised that there is no API method to directly upload file from memory. So if you are looking for it - the shorthand is just to use the write stream returned from createWriteStream() on file object: var gcloud = require( "gcloud" ); var storage = gcloud.storage({projectId: "dir-bg-scraper" }); var sample_TXT_file = "Hello there, \r \n " + "This is sample text file with important info \r \n \r \n " + "Best Regards!" ; storage.createBucket( "dir-bg-scraper" , function (err, bucket, apiResponse) { if (err === null ) { // bucket is the newly created "Test-Bucket" console .log ( "'dir-bg-scraper.appspot.com' successfully created!" ); // create 'README.md' file into this bucket var new_file = bucket.file(...