我不知道在哪里可以找到或学习如何从我的下一个 js 应用程序上传图片到谷歌云存储。有什么想法我该怎么做吗?
async function uploadImages(e) {
if (productImages?.length > 0) {
console.log('we got pictures to upload')
const data = new FormData();
productImages.forEach((element) => {
console.log(element)
data.append("file", element);
});
await fetch('/api/upload', {
method: 'POST',
body: data,
}).then(ress=>ress.text()).then((s)=>console.log(x));
}
}
这是我的上传功能,我需要将图片上传到存储的 post api
Google Cloud 文档对此进行了介绍: