【发布时间】:2018-12-22 13:43:24
【问题描述】:
我正在使用本机反应,并希望将图像上传到 gcp 存储 我没有使用任何应用程序引擎。 根据节点的 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 ,谷歌应用引擎中有一个get_serving_url()函数。
我认为对于谷歌推送通知,谷歌提供每个客户端令牌,以便客户端直接与服务器通信
有什么方法可以直接从客户端上传图片?
【问题讨论】:
标签: node.js google-cloud-platform google-cloud-storage