AWS AmazonS3 documentation change
Summary
Replaced detailed Java SDK code example with a concise instruction to use S3Client for object tagging, linking to API reference documentation
Security assessment
Simplifies code examples without altering security context. Object tagging is a feature but the change does not introduce new security documentation or address vulnerabilities.
Diff
diff --git a/AmazonS3/latest/userguide/tagging-managing.md b/AmazonS3/latest/userguide/tagging-managing.md index 42cbd934a..20ced03d5 100644 --- a//AmazonS3/latest/userguide/tagging-managing.md +++ b//AmazonS3/latest/userguide/tagging-managing.md @@ -52,58 +52 @@ Java -The following example shows how to use the AWS SDK for Java to set tags for a new object and retrieve or replace tags for an existing object. For more information about object tagging, see [Categorizing your objects using tags](./object-tagging.html). For instructions on creating and testing a working sample, see [Getting Started](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/getting-started.html) in the AWS SDK for Java Developer Guide. - - - import com.amazonaws.AmazonServiceException; - import com.amazonaws.SdkClientException; - import com.amazonaws.auth.profile.ProfileCredentialsProvider; - import com.amazonaws.regions.Regions; - import com.amazonaws.services.s3.AmazonS3; - import com.amazonaws.services.s3.AmazonS3ClientBuilder; - import com.amazonaws.services.s3.model.*; - - import java.io.File; - import java.util.ArrayList; - import java.util.List; - - public class ManagingObjectTags { - - public static void main(String[] args) { - Regions clientRegion = Regions.DEFAULT_REGION; - String bucketName = "*** Bucket name ***"; - String keyName = "*** Object key ***"; - String filePath = "*** File path ***"; - - try { - AmazonS3 s3Client = AmazonS3ClientBuilder.standard() - .withCredentials(new ProfileCredentialsProvider()) - .withRegion(clientRegion) - .build(); - - // Create an object, add two new tags, and upload the object to Amazon S3. - PutObjectRequest putRequest = new PutObjectRequest(bucketName, keyName, new File(filePath)); - List<Tag> tags = new ArrayList<Tag>(); - tags.add(new Tag("Tag 1", "This is tag 1")); - tags.add(new Tag("Tag 2", "This is tag 2")); - putRequest.setTagging(new ObjectTagging(tags)); - PutObjectResult putResult = s3Client.putObject(putRequest); - - // Retrieve the object's tags. - GetObjectTaggingRequest getTaggingRequest = new GetObjectTaggingRequest(bucketName, keyName); - GetObjectTaggingResult getTagsResult = s3Client.getObjectTagging(getTaggingRequest); - - // Replace the object's tags with two new tags. - List<Tag> newTags = new ArrayList<Tag>(); - newTags.add(new Tag("Tag 3", "This is tag 3")); - newTags.add(new Tag("Tag 4", "This is tag 4")); - s3Client.setObjectTagging(new SetObjectTaggingRequest(bucketName, keyName, new ObjectTagging(newTags))); - } catch (AmazonServiceException e) { - // The call was transmitted successfully, but Amazon S3 couldn't process - // it, so it returned an error response. - e.printStackTrace(); - } catch (SdkClientException e) { - // Amazon S3 couldn't be contacted for a response, or the client - // couldn't parse the response from Amazon S3. - e.printStackTrace(); - } - } - } - +To manage object tags using the AWS SDK for Java, you can set tags for a new object and retrieve or replace tags for an existing object. For more information about object tagging, see [Categorizing your objects using tags](./object-tagging.html). @@ -110,0 +54 @@ The following example shows how to use the AWS SDK for Java to set tags for a ne +Upload an object to a bucket and set tags using an S3Client. For examples, see [Upload an object to a bucket](https://docs.aws.amazon.com/AmazonS3/latest/API/s3_example_s3_PutObject_section.html) in the _Amazon S3 API Reference_.