简体   繁体   English

如何连接到本地Google Cloud Storage(而非数据存储区)

[英]How to connect to local Google Cloud Storage (not datastore)

I have a web application written in go and want to access a local google cloud storage - GCS (not datastore). 我有一个用Go语言编写的Web应用程序,想要访问本地Google云存储-GCS(不是数据存储区)。 I am not using GAE, I will be using GCE. 我不使用GAE,而是使用GCE。 How do I set up GCS locally and access it from Go? 如何在本地设置GCS并从Go中访问它?

  1. Install gcloud 安装gcloud
  2. In the console run gcloud beta auth application-default login 在控制台中运行gcloud beta auth application-default login
  3. Login with the google account that owns the project 使用拥有该项目的Google帐户登录
  4. In your code, your configuration should be like this: 在您的代码中,您的配置应如下所示:

    cliente, err := storage.NewClient(ctx) cliente,err:= storage.NewClient(ctx)

     if err != nil { log.Fatal(err) } clienteCS = cliente.Bucket(bucketName) 

5)If you haven't created a bucket, I would recomend to creat manually from console or with gsutil because you won't be frequently creating buckets 6)Run your code, enjoy 5)如果您尚未创建存储桶,建议您从控制台gsutil手动创建,因为您不会经常创建存储桶6)运行代码,请尽情享受

Steps from documentation are valid too but is headache 来自文档的步骤也有效,但令人头疼

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM