AWS rekognition documentation change
Summary
Updated Java code example to use S3-based image input instead of local files, added bucket parameter, and simplified imports
Security assessment
Routine code sample update showing S3 integration rather than local file access. No security-specific changes or vulnerabilities addressed
Diff
diff --git a/rekognition/latest/dg/example_rekognition_DetectLabels_section.md b/rekognition/latest/dg/example_rekognition_DetectLabels_section.md index cfd994cb2..395a61c61 100644 --- a//rekognition/latest/dg/example_rekognition_DetectLabels_section.md +++ b//rekognition/latest/dg/example_rekognition_DetectLabels_section.md @@ -794,5 +794,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.*; + @@ -815,2 +812 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - - Usage: <sourceImage> + Usage: <bucketName> <sourceImage> @@ -819 +815,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 @@ -822 +819 @@ 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) { @@ -827,2 +824,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; @@ -833 +831 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - detectImageLabels(rekClient, sourceImage); + detectImageLabels(rekClient, bucketName, sourceImage); @@ -837 +835,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) { @@ -839,2 +844,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(); @@ -842 +848,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. @@ -844 +850 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - .bytes(sourceBytes) + .s3Object(s3ObjectTarget) @@ -859 +865 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - } catch (RekognitionException | FileNotFoundException e) { + } catch (RekognitionException e) {