Javascript Firebase web客户端将JSON上载到云存储

Javascript Firebase web客户端将JSON上载到云存储,javascript,json,firebase,google-cloud-storage,Javascript,Json,Firebase,Google Cloud Storage,我正在使用Firebase web客户端,希望将JSON上载到云存储。我可以使用firebase.storage().ref().child(“/testing.json”)创建引用,但是我不确定如何上传JSON字符串。文档只提到上传文件、blob和base64编码字符串。 例如,我如何完成下面的工作,将JSON字符串上传到云存储,以存储为内容类型为“application/JSON”的JSON文件 const ref=firebase.storage().ref().child(“/testi

我正在使用Firebase web客户端,希望将JSON上载到云存储。我可以使用
firebase.storage().ref().child(“/testing.json”)创建引用,但是我不确定如何上传JSON字符串。文档只提到上传文件、blob和base64编码字符串。
例如,我如何完成下面的工作,将JSON字符串上传到云存储,以存储为内容类型为“application/JSON”的JSON文件

const ref=firebase.storage().ref().child(“/testing.json”);
const jsonString=JSON.stringify({hello:“world”});
参考put()/???

存储ref put可以采用Blob参数。将字符串转换为blob

const ref = firebase.storage().ref().child("/testing.json");
const jsonString = JSON.stringify({ hello: "world" });

const blob = new Blob([jsonString], { type: 'application/json' });
ref.put(blob).then( ... )