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.
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?
Most helpful comment
I'm cool with this. I think our API would have to change slightly to accommodate this change:
That's a little bit awkward, so maybe we can add a method on File instead:
Maybe
saveinstead ofwrite?