New
http://stephenplusplus.github.io/gcloud-node/#/docs/master/storage
Old
Moved to docs: https://docs.google.com/document/d/1SG7DYKEjzX8MiYcPtrKunprT6fgLXIFDsdoVA8ETdow
I took some time to go through what calls the current storage API supports and tried to redesign them to be easier to understand and encapsulate what most developers would like to do with the api. This covers buckets, files, and ACL on them both. The API I propose is below. Let me know if I missed anything or you have questions or a better idea 👍
Initialization
var gcloud = require('gcloud')({ /* optional stuff like credentials */ });
var storage = gcloud.storage;
Buckets
Reference to a bucket (local only, no network request)
var myBucket = storage.bucket('ryan-files');
Create a bucket
storage.createBucket('ryan-files', cb);
Delete a bucket
storage.deleteBucket('ryan-files', cb);
List all buckets
Get metadata about a bucket
storage.getBucket('bucket-name', cb);
// or (pick one)
storage.bucket('ryan-files').getInfo(cb);
Files/Objects
Reference to a file/object in a bucket
myBucket.file('stephen.png');
// or (pick one)
myBucket.object('stephen.png');
Upload an object to a bucket
myBucket.upload('local_filename.png', { name: 'remote_filename.png' /*, other opts too */ }, cb);
// or more simply
myBucket.upload('local_filename.png', 'remote_filename.png', cb);
Remove an object from a bucket
myBucket.remove('remote_filename.png', cb);
// or (pick one)
myBucket.delete('remote_filename.png', cb);
Copy an object from one bucket to another
myBucket.copy('ryan.png', storage.bucket('stephen-files').file('stephen.png'), cb);
ACLs
Create an ACL?
List of scope/permission pairs (may be overkill?)
var myACL = storage.acl(['entity', 'permission', 'entity2', 'permission2']);
Set default object ACL for all objects added to bucket
myBucket.setDefaultACL(myACL, cb);
Clear default ACL for all objects added to bucket
myBucket.clearDefaultACL(myACL, cb);
Get default ACL for all objects added to bucket
myBucket.getDefaultACL(myACL, cb);
Set ACL of bucket
myBucket.setACL(myACL, cb);
Set ACL of file/object
myBucket.file('myfile.png').setACL(myACL, cb);
Clear custom ACL for file/object
myBucket.file('myfile.png').clearACL(cb);
Clear custom ACL for bucket
Get ACL of a file/object
myBucket.file('myfile.png').getACL(cb);
Get ACL of a bucket
Channels
Stop watching resources through this channel
This is provided by storage.channels.stop() in google-api-nodejs-client
New
http://stephenplusplus.github.io/gcloud-node/#/docs/master/storage
Old
Moved to docs: https://docs.google.com/document/d/1SG7DYKEjzX8MiYcPtrKunprT6fgLXIFDsdoVA8ETdow
I took some time to go through what calls the current storage API supports and tried to redesign them to be easier to understand and encapsulate what most developers would like to do with the api. This covers buckets, files, and ACL on them both. The API I propose is below. Let me know if I missed anything or you have questions or a better idea 👍
Initialization
Buckets
Reference to a bucket (local only, no network request)
Create a bucket
Delete a bucket
List all buckets
Get metadata about a bucket
Files/Objects
Reference to a file/object in a bucket
Upload an object to a bucket
Remove an object from a bucket
Copy an object from one bucket to another
ACLs
Create an ACL?
List of scope/permission pairs (may be overkill?)
Set default object ACL for all objects added to bucket
Clear default ACL for all objects added to bucket
Get default ACL for all objects added to bucket
Set ACL of bucket
Set ACL of file/object
Clear custom ACL for file/object
Clear custom ACL for bucket
Get ACL of a file/object
Get ACL of a bucket
Channels
Stop watching resources through this channel
This is provided by
storage.channels.stop()in google-api-nodejs-client