Can you update metadata with gcloud-node

444 Views Asked by At

I'm using gcloud-node to store files on Google Cloud Storage. I would like to update metadata, like the timestamp ala touch. Is that possible?

1

There are 1 best solutions below

0
On BEST ANSWER

You can pass the metadata to bucket.write as in:

data = {
  data: 'Hello World',
  metadata: {
    // ...
  }
};
bucket.write('HelloMessageFile', data, function(err, fileObject) {});

If you want to update the metadata for an existing file, just pass the metadata inside data:

data = {
  metadata: {
    // ...
  }
};
bucket.write('HelloMessageFile', data, function(err, fileObject) {});