Michael Carto
Michael Carto

Reputation: 1

How to update files in Google Cloud Storage with JavaScript

I've recently built a static website with a bucket via the Google Cloud Storage. The bucket includes a JSON file "data.json" which includes all the data required for the website. I knew how to use JavaScript to fetch the JSON file, just simply

fetch("data.json")

But I'll need to update the content in the JSON file and overwrite the file, what should I do then, any ideas?

Upvotes: 0

Views: 459

Answers (1)

nilsf
nilsf

Reputation: 138

The Cloud Storage Client library is not available for JavaScript. But there is the JSON API you could access whith JavaScript.

You have to keep in mind that this would be easy to attack. So there has to be some kind of security.

I would recommend moving your website into a Python Flask App and to use Google Cloud Run. It is really cheap, really simple and you have a native implementation for Cloud Storage.

Upvotes: 1

Related Questions