AWS code-library documentation change
Summary
Updated Rekognition DetectLabels example to use S3 bucket storage instead of local files. Changed imports to wildcard, added bucketName parameter, updated region, and modified image loading from S3 object instead of local file path.
Security assessment
Change transitions from local file access to S3-based access but doesn't address any disclosed vulnerability. Modifies implementation details rather than documenting security features.
Diff
diff --git a/code-library/latest/ug/rekognition_example_rekognition_DetectLabels_section.md b/code-library/latest/ug/rekognition_example_rekognition_DetectLabels_section.md index ef049df50..7e26bb8c1 100644 --- a//code-library/latest/ug/rekognition_example_rekognition_DetectLabels_section.md +++ b//code-library/latest/ug/rekognition_example_rekognition_DetectLabels_section.md @@ -796,5 +796,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - import software.amazon.awssdk.services.rekognition.model.Image; - import software.amazon.awssdk.services.rekognition.model.DetectLabelsRequest; - import software.amazon.awssdk.services.rekognition.model.DetectLabelsResponse; - import software.amazon.awssdk.services.rekognition.model.Label; - import software.amazon.awssdk.services.rekognition.model.RekognitionException; + import software.amazon.awssdk.services.rekognition.model.*; + @@ -817,2 +814 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - - Usage: <sourceImage> + Usage: <bucketName> <sourceImage> @@ -821 +817,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - sourceImage - The path to the image (for example, C:\\AWS\\pic1.png).\s + bucketName - The name of the Amazon S3 bucket where the image is stored + sourceImage - The name of the image file (for example, pic1.png).\s @@ -824 +821 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - if (args.length != 1) { + if (args.length != 2) { @@ -829,2 +826,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - String sourceImage = args[0]; - Region region = Region.US_EAST_1; + String bucketName = args[0] ; + String sourceImage = args[1] ; + Region region = Region.US_WEST_2; @@ -835 +833 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - detectImageLabels(rekClient, sourceImage); + detectImageLabels(rekClient, bucketName, sourceImage); @@ -839 +837,8 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - public static void detectImageLabels(RekognitionClient rekClient, String sourceImage) { + /** + * Detects the labels in an image stored in an Amazon S3 bucket using the Amazon Rekognition service. + * + * @param rekClient the Amazon Rekognition client used to make the detection request + * @param bucketName the name of the Amazon S3 bucket where the image is stored + * @param sourceImage the name of the image file to be analyzed + */ + public static void detectImageLabels(RekognitionClient rekClient, String bucketName, String sourceImage) { @@ -841,2 +846,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - InputStream sourceStream = new FileInputStream(sourceImage); - SdkBytes sourceBytes = SdkBytes.fromInputStream(sourceStream); + S3Object s3ObjectTarget = S3Object.builder() + .bucket(bucketName) + .name(sourceImage) + .build(); @@ -844 +850,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - // Create an Image object for the source image. @@ -846 +852 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - .bytes(sourceBytes) + .s3Object(s3ObjectTarget) @@ -861 +867 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - } catch (RekognitionException | FileNotFoundException e) { + } catch (RekognitionException e) {