Skip to content

Commit

Permalink
readme: update with examples from storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Oct 14, 2014
1 parent 5ca1ac2 commit a12af61
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,24 @@ You need to create a Google Cloud Storage bucket to use this client library. Fol
See [the gcloud-node API documentation](https://googlecloudplatform.github.io/gcloud-node/#/docs/storage) to learn how to connect to the Cloud Storage using this Client Library.

```js
var fs = require('fs');
var gcloud = require('gcloud');
var bucket;

// From Google Compute Engine:
bucket = gcloud.storage.bucket({
bucketName: 'my-bucket'
});
bucket = gcloud.storage.bucket('my-bucket');

// Or from elsewhere:
bucket = gcloud.storage.bucket({
bucketName: 'my-bucket',
keyFilename: '/path/to/the/key.json'
var storage = gcloud.storage({
keyFilename: '/path/to/keyfile.json'
});
bucket = storage.bucket('my-bucket');

bucket.write('demo.txt', 'Hello World', function(err) {
console.log(err || 'Created demo.txt');
});
// Upload a local file to a new file to be created in your bucket:
fs.createReadStream('/local/file.txt').pipe(bucket.file('file.txt'));

// Download a remote file to a new local file:
bucket.file('photo.jpg').pipe(fs.createWriteStream('/local/photo.jpg'));
```

## Contributing
Expand Down

0 comments on commit a12af61

Please sign in to comment.