npm install --save @google-cloud/storage
const Storage = require('@google-cloud/storage'); // Instantiates a client const storage = Storage(); // References an existing bucket, e.g. “my-bucket” const bucket = storage.bucket(bucketName); // Upload a local file to the bucket, e.g. “./local/path/to/file.txt” return bucket.upload(fileName) .then((results) => { const file = results[0]; console.log(`File ${file.name} uploaded`); });
<dependency> <groupid>com.google.cloud</groupid> <artifactid>google-cloud-datastore</artifactid> <version>1.0.0</version> </dependency>
// Imports the Google Cloud Client Library import com.google.cloud.datastore.Datastore; import com.google.cloud.datastore.DatastoreOptions; import com.google.cloud.datastore.Entity; import com.google.cloud.datastore.Key; public class QuickstartSample { public static void main(String... args) throws Exception { // Instantiates a client Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); // The kind for the new entity String kind = "Task"; // The name/ID for the new entity String name = "sampletask1"; // The Cloud Datastore key for the new entity Key taskKey = datastore.newKeyFactory().setKind(kind).newKey(name); // Prepares the new entity Entity task = Entity.newBuilder(taskKey) .set("description", "Buy milk") .build(); // Saves the entity datastore.put(task); } }
pip install --upgrade google-cloud-logging
import logging import google.cloud.logging client = google.cloud.logging.Client() # Attaches a Google Stackdriver logging handler to the root logger client.setup_logging(logging.INFO)
import logging logging.error('This is an error')