Search in sources :

Example 71 with S3Client

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);
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PutObjectRequest(software.amazon.awssdk.services.s3.model.PutObjectRequest) RequestBody(software.amazon.awssdk.core.sync.RequestBody) Test(org.junit.Test)

Example 72 with S3Client

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();
}
Also used : S3ClientBuilder(software.amazon.awssdk.services.s3.S3ClientBuilder) S3Client(software.amazon.awssdk.services.s3.S3Client) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 73 with S3Client

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;
}
Also used : S3Client(uk.co.automatictester.lightning.lambda.s3.S3Client)

Example 74 with S3Client

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;
}
Also used : GetObjectResponse(software.amazon.awssdk.services.s3.model.GetObjectResponse) S3Exception(software.amazon.awssdk.services.s3.model.S3Exception) GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest)

Example 75 with S3Client

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();
}
Also used : Region(software.amazon.awssdk.regions.Region) RekognitionClient(software.amazon.awssdk.services.rekognition.RekognitionClient) S3Client(software.amazon.awssdk.services.s3.S3Client)

Aggregations

S3Client (software.amazon.awssdk.services.s3.S3Client)63 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)53 Region (software.amazon.awssdk.regions.Region)43 ArrayList (java.util.ArrayList)15 GetObjectRequest (software.amazon.awssdk.services.s3.model.GetObjectRequest)12 GetObjectResponse (software.amazon.awssdk.services.s3.model.GetObjectResponse)12 S3Object (software.amazon.awssdk.services.s3.model.S3Object)11 PutObjectRequest (software.amazon.awssdk.services.s3.model.PutObjectRequest)10 List (java.util.List)7 IOException (java.io.IOException)6 RequestBody (software.amazon.awssdk.core.sync.RequestBody)6 CreateBucketRequest (software.amazon.awssdk.services.s3.model.CreateBucketRequest)6 S3Waiter (software.amazon.awssdk.services.s3.waiters.S3Waiter)6 InputStream (java.io.InputStream)5 Test (org.junit.Test)5 ListObjectsRequest (software.amazon.awssdk.services.s3.model.ListObjectsRequest)5 ListObjectsResponse (software.amazon.awssdk.services.s3.model.ListObjectsResponse)5 SupplierEx (com.hazelcast.function.SupplierEx)3 File (java.io.File)3 FileOutputStream (java.io.FileOutputStream)3