I can't seem to upload a file to a folder within a bucket.
var bucket = gcs.bucket('my_bucket/test/');
bucket.upload('hello.txt', function(err, file) {
if (!err) {
console.log("success");
}else{
console.log(err);
}
});
This throws ApiError: Not Found
Am I doing this right? It works when I don't try to put it inside the folder.
Good question! Technically, the Bucket name is the first part, "my_bucket". The file name can have a simulated directory structure by including the "path" in its name. So, basically:
var bucket = gcs.bucket('my_bucket')
bucket.upload('hello.txt', {
destination: 'test/hello.txt'
}, function...
Or to reference the file directly:
var bucket = gcs.bucket('my_bucket')
var file = bucket.file('test/hello.txt')
Most helpful comment
Good question! Technically, the Bucket name is the first part, "my_bucket". The file name can have a simulated directory structure by including the "path" in its name. So, basically:
Or to reference the file directly: