Search in sources :

Example 1 with UnexpectedLengthException

use of com.azure.core.exception.UnexpectedLengthException in project conductor by Netflix.

the class AzureBlobPayloadStorage method upload.

/**
 * Uploads the payload to the given azure blob name.
 * It is expected that the caller retrieves the blob name
 * using {@link #getLocation(Operation, PayloadType, String)} before making this call.
 *
 * @param path        the name of the blob to be uploaded
 * @param payload     an {@link InputStream} containing the json payload which is to be uploaded
 * @param payloadSize the size of the json payload in bytes
 */
@Override
public void upload(String path, InputStream payload, long payloadSize) {
    try {
        BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(path).getBlockBlobClient();
        BlobHttpHeaders blobHttpHeaders = new BlobHttpHeaders().setContentType(CONTENT_TYPE);
        blockBlobClient.uploadWithResponse(payload, payloadSize, blobHttpHeaders, null, null, null, null, null, Context.NONE);
    } catch (BlobStorageException | UncheckedIOException | UnexpectedLengthException e) {
        String msg = "Error communicating with Azure";
        logger.error(msg, e);
        throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, msg, e);
    }
}
Also used : BlobHttpHeaders(com.azure.storage.blob.models.BlobHttpHeaders) BlockBlobClient(com.azure.storage.blob.specialized.BlockBlobClient) UnexpectedLengthException(com.azure.core.exception.UnexpectedLengthException) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) UncheckedIOException(java.io.UncheckedIOException) BlobStorageException(com.azure.storage.blob.models.BlobStorageException)

Aggregations

UnexpectedLengthException (com.azure.core.exception.UnexpectedLengthException)1 BlobHttpHeaders (com.azure.storage.blob.models.BlobHttpHeaders)1 BlobStorageException (com.azure.storage.blob.models.BlobStorageException)1 BlockBlobClient (com.azure.storage.blob.specialized.BlockBlobClient)1 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)1 UncheckedIOException (java.io.UncheckedIOException)1