0
0

More than 3 years have passed since last update.

「Ruby での Cloud Storage の使用」をやってみた

Posted at

Ruby での Cloud Storage の使用 を実施する中で苦労した点を書きます。

環境

  • Windows
  • Ruby
>ruby --version
ruby 2.4.9p362 (2019-10-02 revision 67824) [x64-mingw32]

WindowsでRubyを使おうとするから苦労するのだと思う。。。

コマンドが実行できない

このコマンドが実行できませんでした。

× bundle exec ruby buckets.rb create my-awesome-bucket

Windowsなので拡張子まで書きましょう。

○ bundle exec ruby.exe buckets.rb create my-awesome-bucket

認証が通らない

このページの範囲では認証についての記載を見つけられませんでしたが、次の流れで認証を通せました。

1. 「IAMと管理」よりサービスアカウントを作成する

https://console.cloud.google.com/iam-admin/ からサービスアカウントを追加する。

作成したら、「キーを生成」から、JSONで秘密鍵を含むファイルをダウンロードする。

2. 環境変数の設定

set GOOGLE_APPLICATION_CREDENTIALS=/PATH/TO/project-id-XXXX.json

Windowsでの?ポイント:フォルダ区切り文字は「\」→「/」にする。パスはクオートで囲わない。

3. Google Cloud Storage APIの有効化

https://console.developers.google.com/apis/api/storage-api.googleapis.com からAPIを有効化する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0