為現有的 Batch Operations 作業新增作業標籤
您可以使用 PutJobTagging API 操作,為現有的 Amazon S3 Batch Operations 作業新增作業標籤。如需詳細資訊,請參閱下列範例。
以下示範如何使用 s3control put-job-tagging
,透過 AWS CLI 為 S3 Batch Operations 作業新增作業標籤。若要使用這些範例,請以您自己的資訊取代
。user input placeholders
注意
若傳送此請求時附上空的標籤組,則 Batch Operations 會刪除物件上的現有標籤組。不過,如果您使用此方法,則須支付 Tier 1 Request (PUT
) 的費用。如需詳細資訊,請參閱 Amazon S3 定價
反之,若要刪除 Batch Operations 作業的現有標籤,建議使用 DeleteJobTagging
操作,因為這可以達到相同的結果,而不會產生費用。
-
識別您要用於任務的
TAGS
。在本例中,您套用兩個標籤,
和department
,分別具有數值FiscalYear
和Marketing
。2020
read -d '' TAGS <<EOF [ { "Key": "
department
", "Value": "Marketing
" }, { "Key": "FiscalYear
", "Value": "2020
" } ] EOF -
執行下列
put-job-tagging
命令並提供必要參數:aws \ s3control put-job-tagging \ --account-id
123456789012
\ --tags "${TAGS//$'\n'/}" \ --job-idExample-e25a-4ed2-8bee-7f8ed7fc2f1c
\ --regionus-east-1
下列範例會使用AWS SDK for Java 放置 S3 Batch Operations 作業的標籤。
public void putJobTagging(final AWSS3ControlClient awss3ControlClient, final String jobId) { final S3Tag departmentTag = new S3Tag().withKey("
department
").withValue("Marketing
"); final S3Tag fiscalYearTag = new S3Tag().withKey("FiscalYear
").withValue("2020
"); final PutJobTaggingRequest putJobTaggingRequest = new PutJobTaggingRequest() .withJobId(jobId) .withTags(departmentTag, fiscalYearTag); final PutJobTaggingResult putJobTaggingResult = awss3ControlClient.putJobTagging(putJobTaggingRequest); }