gpt4 book ai didi

node.js - 从应用程序(IOS 或 Android)将图像上传到谷歌云存储

转载 作者:太空宇宙 更新时间:2023-11-03 22:23:03 25 4
gpt4 key购买 nike

我正在使用React Native,并且想要将图像上传到GCP存储我没有使用任何应用程序引擎。根据 Node 的 gcp 文档

const Storage = require('@google-cloud/storage');
const storage = Storage({
projectId: 'id',
keyFilename: 'private-key'
});

const bucketName = 'buckt';

// Uploads a local file to the bucket
storage
.bucket(bucketName)
.upload('filename')
.then(() => {
console.log(`${filename} uploaded to ${bucketName}.`);
})
.catch(err => {
console.error('ERROR:', err);
});

要在客户端中使用此代码,我需要传递我不想这样做的私钥

根据这篇博文https://medium.com/google-cloud/uploading-resizing-and-serving-images-with-google-cloud-platform-ca9631a2c556 ,Google App Engine 中有一个 get_serving_url() 函数。

我认为对于 Google Push 通知,Google 会提供每个客户端 token ,以便客​​户端直接与服务器通信

有什么办法可以直接从客户端上传图片吗?

最佳答案

您可以使用 Firebase 云存储服务。该服务基于 Firebase Auth 凭据,提供从客户端安全上传到 GCP 存储的功能。请参阅:https://firebase.google.com/docs/storage/

关于node.js - 从应用程序(IOS 或 Android)将图像上传到谷歌云存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51337607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com