LoginSignup
2
0

More than 1 year has passed since last update.

Oracle Cloud: MacBookへ wgetをインストールして Object Storageのファイルをダウンロードしてみてみた

Last updated at Posted at 2022-09-01

Object Storageの事前認証済リクエスト(Pre-Authenticated Requests: PAR)を作成すると、一意のURLが生成されます。
このURLを提供するすべてのユーザーは、curlやwgetなどの標準HTTPツールを使用して、事前認証済リクエストで特定されたオブジェクト・ストレージ・リソースにアクセスできます。
ということで、Macbookへ wgetをインストールしてObject Storageのファイルをダウンロードしてみてみます。

■ brewインストール

brew コマンドで iperf3 など Apple が提供していないものをインストールすることができます。
次を参考にbrewをインストール
・参考: Macbook へ brewコマンドをインストールしてみてみた

■ wgetインストール

brewコマンドでwgetをインストール

[user@MacBook ~]$ brew install wget
    ==> Downloading https://ghcr.io/v2/homebrew/core/gettext/manifests/0.21
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/gettext/blobs/sha256:6e2c829031949c0cbd758d0701ed62c191387736e76a98a046c0619907632225
    ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:6e2c829031949c0cbd758d0701ed62c191387736e76a98a046c06199
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/libunistring/manifests/1.0
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/libunistring/blobs/sha256:b8b2f6fe30eefd002bf0dbb5fc0e5c6dc0d5f9b9219f4d6fcddc48e3bc229b23
    ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:b8b2f6fe30eefd002bf0dbb5fc0e5c6dc0d5f9b9219f4d6fcddc48e3
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/libidn2/manifests/2.3.2
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/libidn2/blobs/sha256:fcc51d2c385b19d647da5a53f7041f13f97d2c1119a7cbbfd8433e9e55bf5012
    ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:fcc51d2c385b19d647da5a53f7041f13f97d2c1119a7cbbfd8433e9e
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/wget/manifests/1.21.3
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/wget/blobs/sha256:fc83eec77acee50d2d7ce3bb0cca08d80acccc148e909921de42e57dd5fc7f3d
    ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:fc83eec77acee50d2d7ce3bb0cca08d80acccc148e909921de42e57d
    ######################################################################## 100.0%
    ==> Installing dependencies for wget: gettext, libunistring and libidn2
    ==> Installing wget dependency: gettext
    ==> Pouring gettext--0.21.arm64_monterey.bottle.tar.gz
    🍺  /opt/homebrew/Cellar/gettext/0.21: 1,953 files, 20.6MB
    ==> Installing wget dependency: libunistring
    ==> Pouring libunistring--1.0.arm64_monterey.bottle.tar.gz
    🍺  /opt/homebrew/Cellar/libunistring/1.0: 56 files, 5.0MB
    ==> Installing wget dependency: libidn2
    ==> Pouring libidn2--2.3.2.arm64_monterey.bottle.tar.gz
    🍺  /opt/homebrew/Cellar/libidn2/2.3.2: 77 files, 885.4KB
    ==> Installing wget
    ==> Pouring wget--1.21.3.arm64_monterey.bottle.tar.gz
    🍺  /opt/homebrew/Cellar/wget/1.21.3: 89 files, 4.2MB
    ==> `brew cleanup` has not been run in the last 30 days, running now...
    Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
    Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
    Removing: /Users/user/Library/Logs/Homebrew/iperf3... (64B)
    Removing: /Users/user/Library/Logs/Homebrew/ca-certificates... (64B)
    Removing: /Users/user/Library/Logs/Homebrew/openssl@1.1... (64B)
    Pruned 0 symbolic links and 2 directories from /opt/homebrew

■ OCI Object Storageのファイルをダウンロード

● 事前認証済リクエスト(PAR)作成

バケット内の特定のオブジェクトに対して読取りアクセス権を付与するPARを作成

1) Object Storage バケット画面
対象ファイルの右端にあるリスト・アイコンをクリックして[事前認証済リクエストの作成]をクリック
11_PAR作成02.jpg

2)事前認証済リクエストの作成画面
次の項目を設定し、[事前認証済リクエストの作成をクリック]

・名前: 任意の名前; デフォルト名を変更する場合は、文字、数字、ダッシュ、アンダースコアおよびピリオドのみを使用
・事前認証済リクエスト・ターゲット: [バケット]はデフォルトで選択されていますが、別のターゲットを選択することもできます
・アクセス・タイプ: 次のタイプのいずれかを選択
    オブジェクト読取りを許可(デフォルト)
    オブジェクト書込みを許可
    オブジェクトの読取りと書込みを許可
・有効期限: 日時エディタを使用して有効期限日時を設定

11_PAR作成03.jpg

3) 事前認証済リクエストの詳細画面
事前認証済リクエストのURLをコピーします。これは再度表示されません。

11_PAR作成04.jpg

■ wgetでファイル・ダウンロード

● wget実行

作成した事前認証済リクエスト(PAR)のURLを使用して、wgetでダウンロード

[user@MacBook ~]$ wget https://objectstorage.ap-tokyo-1.oraclecloud.com/p/Czc2snns6M9fcPQY9btZtwfg9nHPwTpwE/n/POC/b/test-bucket01/o/test-file.txt
    --2022-09-01 18:51:18--  https://objectstorage.ap-tokyo-1.oraclecloud.com/p/Czc2snns6M9fcPQY9btZtwfg9nHPwTpwE/n/POC/b/test-bucket01/o/test-file.txt
    objectstorage.ap-tokyo-1.oraclecloud.com (objectstorage.ap-tokyo-1.oraclecloud.com) をDNSに問いあわせています... 134.70.80.3
    objectstorage.ap-tokyo-1.oraclecloud.com (objectstorage.ap-tokyo-1.oraclecloud.com)|134.70.80.3|:443 に接続しています... 接続しました。
    HTTP による接続要求を送信しました、応答を待っています... 200 OK
    長さ: 38 [application/x-www-form-urlencoded]
    `test-file.txt' に保存中

    test-file.txt                       100%[================================================================>]      38  --.-KB/s 時間 0s

    2022-09-01 18:51:18 (36.2 MB/s) - `test-file.txt' へ保存完了 [38/38]

● ファイル・ダウンロード確認

[user@MacBook ~]$ ls -l
    -rw-r--r--  1 user  staff  38 Aug 31 18:01 test-file.txt

■ 参考

 ・事前認証済リクエストの使用
 ・GNU Wget
 ・Homebrewはどんなことをする?

2
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
2
0