Search in sources :

Example 36 with S3Client

use of org.jclouds.s3.S3Client in project legacy-jclouds-examples by jclouds.

the class MainApp method main.

public static void main(String[] args) throws IOException {
    if (args.length < PARAMETERS)
        throw new IllegalArgumentException(INVALID_SYNTAX);
    // Args
    String provider = args[0];
    // note that you can check if a provider is present ahead of time
    checkArgument(contains(allKeys, provider), "provider %s not in supported list: %s", provider, allKeys);
    String identity = args[1];
    String credential = args[2];
    String containerName = args[3];
    // Init
    BlobStoreContext context = ContextBuilder.newBuilder(provider).credentials(identity, credential).buildView(BlobStoreContext.class);
    try {
        // Create Container
        BlobStore blobStore = context.getBlobStore();
        blobStore.createContainerInLocation(null, containerName);
        // Add Blob
        Blob blob = blobStore.blobBuilder("test").payload("testdata").build();
        blobStore.putBlob(containerName, blob);
        // List Container
        for (StorageMetadata resourceMd : blobStore.list()) {
            if (resourceMd.getType() == StorageType.CONTAINER || resourceMd.getType() == StorageType.FOLDER) {
                // Use Map API
                Map<String, InputStream> containerMap = context.createInputStreamMap(resourceMd.getName());
                System.out.printf("  %s: %s entries%n", resourceMd.getName(), containerMap.size());
            }
        }
        // Use Provider API
        if (context.getBackendType().getRawType().equals(RestContext.class)) {
            RestContext<?, ?> rest = context.unwrap();
            if (rest.getApi() instanceof S3Client) {
                RestContext<S3Client, S3AsyncClient> providerContext = context.unwrap();
                providerContext.getApi().getBucketLogging(containerName);
            } else if (rest.getApi() instanceof SwiftClient) {
                RestContext<SwiftClient, SwiftAsyncClient> providerContext = context.unwrap();
                providerContext.getApi().getObjectInfo(containerName, "test");
            } else if (rest.getApi() instanceof AzureBlobClient) {
                RestContext<AzureBlobClient, AzureBlobAsyncClient> providerContext = context.unwrap();
                providerContext.getApi().getBlobProperties(containerName, "test");
            } else if (rest.getApi() instanceof AtmosClient) {
                RestContext<AtmosClient, AtmosAsyncClient> providerContext = context.unwrap();
                providerContext.getApi().getSystemMetadata(containerName + "/test");
            }
        }
    } finally {
        // Close connecton
        context.close();
        System.exit(0);
    }
}
Also used : StorageMetadata(org.jclouds.blobstore.domain.StorageMetadata) Blob(org.jclouds.blobstore.domain.Blob) SwiftClient(org.jclouds.openstack.swift.SwiftClient) InputStream(java.io.InputStream) RestContext(org.jclouds.rest.RestContext) AtmosClient(org.jclouds.atmos.AtmosClient) S3AsyncClient(org.jclouds.s3.S3AsyncClient) BlobStoreContext(org.jclouds.blobstore.BlobStoreContext) S3Client(org.jclouds.s3.S3Client) AzureBlobClient(org.jclouds.azureblob.AzureBlobClient) BlobStore(org.jclouds.blobstore.BlobStore) AzureBlobAsyncClient(org.jclouds.azureblob.AzureBlobAsyncClient)

Example 37 with S3Client

use of org.jclouds.s3.S3Client in project pravega by pravega.

the class S3SimpleStorageFactory method createStorageAdapter.

@Override
public Storage createStorageAdapter(int containerId, ChunkMetadataStore metadataStore) {
    S3Client s3Client = createS3Client(this.config);
    ChunkedSegmentStorage chunkedSegmentStorage = new ChunkedSegmentStorage(containerId, new S3ChunkStorage(s3Client, this.config, this.executor, true), metadataStore, this.executor, this.chunkedSegmentStorageConfig);
    return chunkedSegmentStorage;
}
Also used : ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 38 with S3Client

use of org.jclouds.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 39 with S3Client

use of org.jclouds.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 40 with S3Client

use of org.jclouds.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 Region (software.amazon.awssdk.regions.Region)43 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)8 S3Object (software.amazon.awssdk.services.s3.model.S3Object)7 List (java.util.List)5 GetObjectRequest (software.amazon.awssdk.services.s3.model.GetObjectRequest)5 GetObjectResponse (software.amazon.awssdk.services.s3.model.GetObjectResponse)5 SupplierEx (com.hazelcast.function.SupplierEx)4 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)3 S3ClientBuilder (software.amazon.awssdk.services.s3.S3ClientBuilder)3 Pipeline (com.hazelcast.jet.pipeline.Pipeline)2 TestSources (com.hazelcast.jet.pipeline.test.TestSources)2 ILogger (com.hazelcast.logging.ILogger)2 Logger (com.hazelcast.logging.Logger)2 HazelcastSerialClassRunner (com.hazelcast.test.HazelcastSerialClassRunner)2 Collectors (java.util.stream.Collectors)2 AfterClass (org.junit.AfterClass)2 Test (org.junit.Test)2