本文介绍了如何使用带有 gsutil 的服务帐户上传到 CS + BigQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用我在 Google API 控制台中创建的服务帐户,使用 gsutil 将数据上传到 Google BigQuery?

How do I upload data to Google BigQuery with gsutil, by using a Service Account I created in the Google APIs Console?

首先,我尝试使用 gsutil 将数据上传到 Cloud Storage,就像这样成为推荐机型.在 Gmail 用户批准后一切正常,但不允许我使用服务帐户.

First I'm trying to upload data to Cloud Storage using gsutil, as that seems to be the recommended model. Everything works fine with gmail user approval, but it does not allow me to use a service account.

似乎我可以使用 Python API 来获取使用 签名的 JWT 凭据的访问令牌,但我更喜欢使用像 gsutil 这样支持可恢复上传等的命令行工具.

It seems I can use the Python API to get an access token using signed JWT credentials, but I would prefer using a command-line tool like gsutil with support for resumable uploads etc.

我想每天晚上在 cron 中使用 gsutil 将文件上传到 Cloud Storage,然后将它们导入到 BigQuery.

I would like to use gsutil in a cron to upload files to Cloud Storage every night and then import them to BigQuery.

任何帮助或方向将不胜感激.

Any help or directions to go would be appreciated.

推荐答案

Google Cloud Storage 刚刚发布了 gsutil 的新版本 (3.26),该版本支持服务帐户(以及许多其他功能和错误修复).如果您已经安装了 gsutil,则可以通过运行以下命令获取此版本:

Google Cloud Storage just released a new version (3.26) of gsutil that supports service accounts (as well as a number of other features and bug fixes). If you already have gsutil installed you can get this version by running:

gsutil 更新

简而言之,您可以通过运行以下命令来配置服务帐户:

In brief, you can configure a service account by running:

gsutil 配置 -e

有关使用 config 命令的更多详细信息,请参阅 gsutil help config.
有关 gsutil 支持的不同类型的凭据(以及不同的用例)的信息,请参阅 gsutil 帮助凭据.

See gsutil help config for more details about using the config command.
See gsutil help creds for information about the different flavors of credentials (and different use cases) that gsutil supports.

Mike Schwartz,Google 云存储团队

Mike Schwartz, Google Cloud Storage Team

这篇关于如何使用带有 gsutil 的服务帐户上传到 CS + BigQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:08