use of software.amazon.awssdk.services.s3.S3Client in project data-transfer-project by google.
the class BackblazeDataTransferClientTest method testUploadFileSingle.
@Test
public void testUploadFileSingle() throws BackblazeCredentialsException, IOException {
// Arrange
final String expectedVersionId = "123";
createValidBucketList();
when(s3Client.putObject(any(PutObjectRequest.class), any(RequestBody.class))).thenReturn(PutObjectResponse.builder().versionId(expectedVersionId).build());
BackblazeDataTransferClient client = createDefaultClient();
client.init(KEY_ID, APP_KEY, EXPORT_SERVICE);
// Act
String actualVersionId = client.uploadFile(FILE_KEY, testFile);
// Assert
verify(s3Client, times(1)).putObject(any(PutObjectRequest.class), any(RequestBody.class));
assertEquals(expectedVersionId, actualVersionId);
}
use of software.amazon.awssdk.services.s3.S3Client in project fluency by komamitsu.
the class AwsS3SenderTest method close.
@Test
void close() {
S3Client s3Client = mock(S3Client.class);
S3ClientBuilder s3ClientBuilder = mock(S3ClientBuilder.class);
doReturn(s3Client).when(s3ClientBuilder).build();
AwsS3Sender sender = new AwsS3Sender(s3ClientBuilder);
sender.close();
verify(s3Client, times(1)).close();
}
use of software.amazon.awssdk.services.s3.S3Client in project lightning by automatictester.
the class LightningHandler method handleRequest.
public LightningResponse handleRequest(LightningRequest lightningRequest, Context context) {
parseRequestParams(lightningRequest);
s3Client = new S3Client(region, bucket);
if (mode.equals("verify")) {
runTests();
String junitReportS3Path = saveJunitReportToS3();
response.setJunitReport(junitReportS3Path);
} else if (mode.equals("report")) {
runReport();
}
notifyCIServer();
return response;
}
use of software.amazon.awssdk.services.s3.S3Client in project aws-doc-sdk-examples by awsdocs.
the class DetectPPE method getObjectBytes.
public static byte[] getObjectBytes(S3Client s3, String bucketName, String keyName) {
try {
GetObjectRequest objectRequest = GetObjectRequest.builder().key(keyName).bucket(bucketName).build();
ResponseBytes<GetObjectResponse> objectBytes = s3.getObjectAsBytes(objectRequest);
byte[] data = objectBytes.asByteArray();
return data;
} catch (S3Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return null;
}
use of software.amazon.awssdk.services.s3.S3Client in project aws-doc-sdk-examples by awsdocs.
the class DisplayFacesFrame method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <sourceImage> <bucketName>\n\n" + "Where:\n" + " sourceImage - the name of the image in an Amazon S3 bucket (for example, people.png). \n\n" + " bucketName - the name of the Amazon S3 bucket (for example, myBucket). \n\n";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String sourceImage = args[0];
String bucketName = args[1];
Region region = Region.US_EAST_1;
S3Client s3 = S3Client.builder().region(region).build();
RekognitionClient rekClient = RekognitionClient.builder().region(region).build();
displayAllFaces(s3, rekClient, sourceImage, bucketName);
s3.close();
rekClient.close();
}
Aggregations