Search in sources :

Example 51 with AsyncRequestBody

use of software.amazon.awssdk.core.async.AsyncRequestBody in project aws-sdk by reactiverse.

the class VertxS3ClientSpec method publishImageToBucket.

@Test
@Order(3)
void publishImageToBucket(Vertx vertx, VertxTestContext ctx) throws Exception {
    final Context originalContext = vertx.getOrCreateContext();
    final S3AsyncClient s3 = s3(originalContext);
    readFileFromDisk(vertx).flatMap(file -> {
        final AsyncRequestBody body = AsyncRequestBody.fromPublisher(new ReadStreamPublisher<>(file.getDelegate()));
        return single(s3.putObject(VertxS3ClientSpec::uploadImgReq, body));
    }).subscribe(putFileRes -> {
        assertContext(vertx, originalContext, ctx);
        ctx.verify(() -> {
            assertNotNull(putFileRes.eTag());
            ctx.completeNow();
        });
    }, ctx::failNow);
}
Also used : VertxTestContext(io.vertx.junit5.VertxTestContext) Context(io.vertx.core.Context) VertxTestContext(io.vertx.junit5.VertxTestContext) Bucket(software.amazon.awssdk.services.s3.model.Bucket) BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) S3Object(software.amazon.awssdk.services.s3.model.S3Object) LocalStackBaseSpec(io.reactiverse.awssdk.integration.LocalStackBaseSpec) VertxAsyncResponseTransformer(io.reactiverse.awssdk.converters.VertxAsyncResponseTransformer) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Order(org.junit.jupiter.api.Order) Single(io.reactivex.Single) Context(io.vertx.core.Context) Timeout(io.vertx.junit5.Timeout) GetObjectResponse(software.amazon.awssdk.services.s3.model.GetObjectResponse) Mimetype(software.amazon.awssdk.core.internal.util.Mimetype) ArrayList(java.util.ArrayList) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) WriteStream(io.vertx.core.streams.WriteStream) CreateBucketRequest(software.amazon.awssdk.services.s3.model.CreateBucketRequest) GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) Pump(io.vertx.core.streams.Pump) PutObjectRequest(software.amazon.awssdk.services.s3.model.PutObjectRequest) EnabledIfSystemProperty(org.junit.jupiter.api.condition.EnabledIfSystemProperty) AsyncResponseTransformer(software.amazon.awssdk.core.async.AsyncResponseTransformer) AsyncResult(io.vertx.core.AsyncResult) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MessageProducer(io.vertx.core.eventbus.MessageProducer) ReadStreamPublisher(io.reactiverse.awssdk.reactivestreams.ReadStreamPublisher) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) ListObjectsRequest(software.amazon.awssdk.services.s3.model.ListObjectsRequest) OpenOptions(io.vertx.core.file.OpenOptions) S3AsyncClient(software.amazon.awssdk.services.s3.S3AsyncClient) Vertx(io.vertx.core.Vertx) LocalstackDockerExtension(cloud.localstack.docker.LocalstackDockerExtension) ListObjectsV2Request(software.amazon.awssdk.services.s3.model.ListObjectsV2Request) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) MethodOrderer(org.junit.jupiter.api.MethodOrderer) Nullable(io.vertx.codegen.annotations.Nullable) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Buffer(io.vertx.core.buffer.Buffer) AsyncFile(io.vertx.reactivex.core.file.AsyncFile) AsyncRequestBody(software.amazon.awssdk.core.async.AsyncRequestBody) LocalstackDockerProperties(cloud.localstack.docker.annotation.LocalstackDockerProperties) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Handler(io.vertx.core.Handler) AsyncRequestBody(software.amazon.awssdk.core.async.AsyncRequestBody) ReadStreamPublisher(io.reactiverse.awssdk.reactivestreams.ReadStreamPublisher) S3AsyncClient(software.amazon.awssdk.services.s3.S3AsyncClient) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Aggregations

AsyncRequestBody (software.amazon.awssdk.core.async.AsyncRequestBody)51 ByteBuffer (java.nio.ByteBuffer)25 Test (org.junit.jupiter.api.Test)24 List (java.util.List)17 Test (org.junit.Test)13 Subscriber (org.reactivestreams.Subscriber)12 CompletableFuture (java.util.concurrent.CompletableFuture)11 SdkHttpFullRequest (software.amazon.awssdk.http.SdkHttpFullRequest)11 Publisher (org.reactivestreams.Publisher)9 Flowable (io.reactivex.Flowable)8 Consumer (java.util.function.Consumer)8 AsyncAws4Signer (software.amazon.awssdk.auth.signer.AsyncAws4Signer)8 AsyncResponseTransformer (software.amazon.awssdk.core.async.AsyncResponseTransformer)8 Signer (software.amazon.awssdk.core.signer.Signer)8 MetricCollector (software.amazon.awssdk.metrics.MetricCollector)8 Collections (java.util.Collections)7 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7 Generated (software.amazon.awssdk.annotations.Generated)7 SdkInternalApi (software.amazon.awssdk.annotations.SdkInternalApi)7