如何将Google Cloud Storage与react.js结合使用? [英] How to use Google Cloud Storage with react.js?

查看:61
本文介绍了如何将Google Cloud Storage与react.js结合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行在Express上运行的react.js应用.我添加了 google-cloud npm模块,但是我没有设法做到这一点工作.当我需要该模块时,在控制台中出现以下错误:

I'm running a react.js app that runs on Express. I added the google-cloud npm module, yet I haven't managed to make it work. When I require the module, I get the following error in my console:

似乎npm模块有望在服务器端运行,而react.js在客户端运行.有没有人尝试使用react.js应用将文件上传到Google Cloud Storage?

It seems the npm module is expected to run server-side, yet react.js runs client-side. Has anyone tried uploading a file to Google Cloud Storage with a react.js app?

推荐答案

有一个适用于Google API的JavaScript客户端库,您可以将其与Google Cloud Platform一起使用. 这里是一个教程,向您展示如何将其与Compute Engine API结合使用.在Google Cloud Storage中使用它的原理应该相似.

There's a JavaScript client library for Google APIs you can use with Google Cloud Platform. Here's a tutorial that shows you how to use it with Compute Engine APIs. The principles for using it with Google Cloud Storage should be similar.

您的OAuth API范围需要与Cloud Storage JSON API匹配,并且您需要 Cloud Storage JSON API 根据需要,以与本教程相同的样式使用计算引擎API .

Your OAuth API scopes need to match the Cloud Storage JSON API, and you'll need to load a storage client instead of compute. From there you can use the Cloud Storage JSON API as needed, in the same style as the tutorial uses the Compute Engine API.

这篇关于如何将Google Cloud Storage与react.js结合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆