{OCI オブジェクト・ストレージ} 事前認証済リクエストの作成

https://oracle-japan.github.io/ocitutorials/beginners/object-storage/#3-%E4%BA%8B%E5%89%8D%E8%AA%8D%E8%A8%BC%E6%B8%88%E3%83%AA%E3%82%AF%E3%82%A8%E3%82%B9%E3%83%88%E3%81%AE%E4%BD%9C%E6%88%90

https://docs.oracle.com/ja-jp/iaas/Content/Object/Tasks/usingpreauthenticatedrequests_topic-To_create_a_preauthenticated_request_for_all_objects_in_a_bucket.htm

 

-- 1. バケット作成


oci os bucket list \
--compartment-id ocid1.compartment.oc1..000000000000000000000000000000000000000000000000000000000000 

 

oci os bucket create \
--compartment-id ocid1.compartment.oc1..000000000000000000000000000000000000000000000000000000000000 \
--name bucket01 \
--auto-tiering Disabled \
--object-events-enabled false \
--public-access-type NoPublicAccess \
--storage-tier Standard \
--versioning Disabled


-- 2. テストオブジェクト作成


echo test01 > file01.txt
echo test02 > file02.txt

oci os object list \
--bucket-name bucket01


oci os object put \
--bucket-name bucket01 \
--file file01.txt \
--name file01.txt

oci os object put \
--bucket-name bucket01 \
--file file02.txt \
--name file02.txt


-- 3. 事前認証済リクエスト作成

oci os preauth-request list \
--bucket-name bucket01 


oci os preauth-request create \
--access-type ObjectRead \
--bucket-name bucket01 \
--name pr01 \
--time-expires 2024-01-03T08:40:00Z \
--object-name file01.txt 


-- 4. 動作確認

curl https://objectstorage.us-ashburn-1.oraclecloud.com/p/0000000000000000000000000000000000000000000000000000000000000000/n/111111111111/b/bucket01/o/file01.txt

 

 

-- 5. クリーンアップ

事前認証済リクエスト削除

oci os preauth-request list \
--bucket-name bucket01 


oci os preauth-request delete \
--bucket-name bucket01 \
--par-id 0000000000000000000000000000000000000000000000000000000000000000:file01.txt \
--force

 

 

バケット削除

oci os bucket list \
--compartment-id ocid1.compartment.oc1..000000000000000000000000000000000000000000000000000000000000 

oci os bucket delete \
--name bucket01 \
--empty \
--force