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.
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: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
writableStreamor 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.