Google-cloud-node: Allow byte uploads in upload, not just file uploads.

Created on 22 Mar 2016  路  1Comment  路  Source: googleapis/google-cloud-node

Currently the bucket.upload() API provides uploads from the local file system, and any streaming requests have to happen by opening a writable stream. We should provide an API to allow upload to consume either a path on the file system, or a byte array. Like so:

var options = {
  destination: 'hello.txt'
}

var data = ['h', 'e', 'l', 'l', 'o', '!']

bucket.upload(data, options, function(err, file) {
  // File hello.txt contains 'hello!'
});

Also, I get that byte uploads allow people to do terrible, unscalable things, so we should preface the docs by saying that for large files they should stream the file using a writableStream or upload from a file on disk. That said, I think this is a nice convenience method that allows devs to get up and running quickly from files they already have in memory.

storage

Most helpful comment

I'm cool with this. I think our API would have to change slightly to accommodate this change:

var options = {
  destination: 'hello.txt'
};

bucket.upload({
  data: 'hello!'
}, options, callback);

That's a little bit awkward, so maybe we can add a method on File instead:

file.write('hello', [options], callback);

Maybe save instead of write?

>All comments

I'm cool with this. I think our API would have to change slightly to accommodate this change:

var options = {
  destination: 'hello.txt'
};

bucket.upload({
  data: 'hello!'
}, options, callback);

That's a little bit awkward, so maybe we can add a method on File instead:

file.write('hello', [options], callback);

Maybe save instead of write?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

charly37 picture charly37  路  3Comments

sabrehagen picture sabrehagen  路  4Comments

ddunkin picture ddunkin  路  3Comments

stephenplusplus picture stephenplusplus  路  4Comments

pputhran picture pputhran  路  4Comments