usingSystem.IO;usingGroupDocs.Viewer.Options;usingGroupDocs.Viewer;usingAzure.Storage.Blobs;// ...stringblobName="sample.docx";Streamstream=DownloadFile(blobName);LoadOptionsloadOptions=newLoadOptions(FileType.DOCX);using(Viewerviewer=newViewer(stream,loadOptions)){HtmlViewOptionsviewOptions=HtmlViewOptions.ForEmbeddedResources();viewer.View(viewOptions);}staticStreamDownloadFile(stringblobName){BlobContainerClientcontainerClient=GetContainerClient();// Get a reference to a blobBlobClientblobClient=containerClient.GetBlobClient(blobName);MemoryStreammemoryStream=newMemoryStream();blobClient.DownloadTo(memoryStream);memoryStream.Position=0;returnmemoryStream;}staticBlobContainerClientGetContainerClient(){stringaccountName="***";stringaccountKey="***";stringendpointSuffix="core.windows.net";stringcontainerName="***";stringconnectionString=$"DefaultEndpointsProtocol=https;AccountName={accountName};AccountKey={accountKey};EndpointSuffix={endpointSuffix}";// Create a BlobContainerClient object which will be used to create a container clientBlobContainerClientblobContainerClient=newBlobContainerClient(connectionString,containerName);returnblobContainerClient;}
ImportsSystem.IOImportsGroupDocs.Viewer.OptionsImportsGroupDocs.ViewerImportsAzure.Storage.Blobs' ...
ModuleProgramSubMain(argsAsString())DimblobNameAsString="sample.docx"DimstreamAsStream=DownloadFile(blobName)DimloadOptionsAsNewLoadOptions(FileType.DOCX)UsingviewerAsNewViewer(stream,loadOptions)DimviewOptionsAsHtmlViewOptions=HtmlViewOptions.ForEmbeddedResources()viewer.View(viewOptions)EndUsingEndSubPrivateFunctionDownloadFile(ByValblobNameAsString)AsStreamDimcontainerClientAsBlobContainerClient=GetContainerClient()' Get a reference to a blob
DimblobClientAsBlobClient=containerClient.GetBlobClient(blobName)DimmemoryStreamAsNewMemoryStream()blobClient.DownloadTo(memoryStream)memoryStream.Position=0ReturnmemoryStreamEndFunctionPrivateFunctionGetContainerClient()AsBlobContainerClientDimaccountNameAsString="***"DimaccountKeyAsString="***"DimendpointSuffixAsString="core.windows.net"DimcontainerNameAsString="***"DimconnectionStringAsString=$"DefaultEndpointsProtocol=https;AccountName={accountName};AccountKey={accountKey};EndpointSuffix={ _
endpointSuffix}"' Create a BlobContainerClient object which will be used to create a container client
DimblobContainerClientAsNewBlobContainerClient(connectionString,containerName)ReturnblobContainerClientEndFunctionEndModule
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.