Load from Azure Blob Storage

Note

The following code snippet shows how to load a document from Azure Blob Storage:

import com.azure.identity.DefaultAzureCredential;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.storage.blob.BlobClient;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.blob.specialized.BlobInputStream;
import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
// ...

DefaultAzureCredential defaultCredential = new DefaultAzureCredentialBuilder()
        .build();

BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
        .endpoint("https://{accountName}.blob.core.windows.java/")
        .credential(defaultCredential)
        .buildClient();

BlobContainerClient blobContainerClient = blobServiceClient.createBlobContainer("container-name");
BlobClient blobClient = blobContainerClient.getBlobClient("sample.docx");

try (final BlobInputStream blobInputStream = blobClient.openInputStream();
     Viewer viewer = new Viewer(blobInputStream)) {
    HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();

    viewer.view(viewOptions);
}