AdSense

網頁

2023/5/10

AWS CLI 透過S3 bucket access point取得物件

使用AWS CLI透過S3 bucket的access point取得object(物件,即檔案)。


範例環境:

  • macOS
  • AWS CLI version 2 (aws-cli/2.9.19)


例如在S3 bucket有一object為hello.txt,而bucket有一名稱為my-access-point的access point的ARNarn:aws:s3:ap-northeast-1:423456789012:accesspoint/my-access-point

在目錄~/Documents以命令列輸入AWS CLI命令aws s3api get-object --key hello.txt --bucket arn:aws:s3:ap-northeast-1:423456789012:accesspoint/my-access-point download.txt會把hello.txt下載至執行命令所在目錄的download.txt

~/Documents% aws s3api get-object --key hello.txt --bucket arn:aws:s3:ap-northeast-1:423456789012:accesspoint/my-access-point download.txt
{
    "AcceptRanges": "bytes",
    "LastModified": "2023-05-09T08:33:44+00:00",
    "ContentLength": 11,
    "ETag": "\"5eb63bbbe01eeed093cb22bb8f5acdc3\"",
    "ContentType": "text/plain",
    "ServerSideEncryption": "AES256",
    "Metadata": {}
}

執行後在~/Documents目錄可看到下載的download.txt


沒有留言:

AdSense