@Override
    public WriteStream<Buffer> drainHandler(Handler<Void> handler) {
        vertx.executeBlocking(() -> {
            synchronized (BlobWriteStream.this) {
                try {
                    if (resourceUpload == null) {
                        resourceUpload = resourceService.initFileUpload(resource, contentType, etag, author);
                    }

                    ByteBuf chunk = chunkBuffer.slice(0, position).getByteBuf();
                    resourceUpload.addChunk(chunk);
                    position = 0;
                    isBufferFull = false;
                } catch (Throwable ex) {
                    exception = ex;
                } finally {
                    if (handler != null) {
                        handler.handle(null);
                    }
                }
            }
            return null;
        });

        return this;
    }
Implementation of vertx {@link io.vertx.core.streams.WriteStream} that handles data chunks (from {@link io.vertx.core.streams.ReadStream}) and writes them to the blob storage.
If file content is bigger than 5MB - multipart upload will be used.
Chunk size can be configured via {@link #setWriteQueueMaxSize(int)} method, but should be no less than 5 MB according to the s3 specification.
If any exception is caught in between - multipart upload will be aborted.
server/src/main/java/com/epam/aidial/core/server/vertx/stream/BlobWriteStream.java