AWS rekognition documentation change
Summary
Modified example to use S3 bucket references instead of local file paths, updated parameter handling, and added method documentation
Security assessment
Changes demonstrate using S3 for image storage instead of local filesystem access, but do not address specific security vulnerabilities or document new security features
Diff
diff --git a/rekognition/latest/dg/images-bytes.md b/rekognition/latest/dg/images-bytes.md index 59dd9dfd3..b332b2e50 100644 --- a//rekognition/latest/dg/images-bytes.md +++ b//rekognition/latest/dg/images-bytes.md @@ -304,5 +304,2 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - 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.*; + @@ -325,2 +322 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - - Usage: <sourceImage> + Usage: <bucketName> <sourceImage> @@ -329 +325,2 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - 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 @@ -332 +329 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - if (args.length != 1) { + if (args.length != 2) { @@ -337,2 +334,3 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - String sourceImage = args[0]; - Region region = Region.US_EAST_1; + String bucketName = args[0] ; + String sourceImage = args[1] ; + Region region = Region.US_WEST_2; @@ -343 +341 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - detectImageLabels(rekClient, sourceImage); + detectImageLabels(rekClient, bucketName, sourceImage); @@ -347 +345,8 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - 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) { @@ -349,2 +354,4 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - InputStream sourceStream = new FileInputStream(sourceImage); - SdkBytes sourceBytes = SdkBytes.fromInputStream(sourceStream); + S3Object s3ObjectTarget = S3Object.builder() + .bucket(bucketName) + .name(sourceImage) + .build(); @@ -352 +358,0 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - // Create an Image object for the source image. @@ -354 +360 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - .bytes(sourceBytes) + .s3Object(s3ObjectTarget) @@ -369 +375 @@ This code is taken from the AWS Documentation SDK examples GitHub repository. Se - } catch (RekognitionException | FileNotFoundException e) { + } catch (RekognitionException e) {