Skip to content

storage: API proposal #194

@ryanseys

Description

@ryanseys

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

storage.listBuckets(cb);

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

myBucket.clearACL(cb);

Get ACL of a file/object

myBucket.file('myfile.png').getACL(cb);

Get ACL of a bucket

myBucket.getACL(cb);

Channels

Stop watching resources through this channel

This is provided by storage.channels.stop() in google-api-nodejs-client

storage.stopChannels();

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions