I want to refer to a document(s) in azure blob storage and perform. some operations like mail-merge etc. and generate the Result file(s) to another Folder in the same blob storage using C#.
Also Merge the document in the Result Folder at the End.
I have done this locally by using folders in disk,but is this can be done with the folders in blob storage
Is this possible? without downloading file to local folder?
Currently, we are checking your requirement. We will share the details tomorrow 4th May 2023.
Anto Nihil S
From the given details, we have found that your requirement is to download the Word document from Azure blob storage to perform some operations like mail merge or merge Word documents. Then upload the saved Word document to Azure blob storage.
Syncfusion Word (DocIO) library has API’s to load and save the Word document as a stream. Please refer the below UG documentation links to know about this,
To achieve your requirement, we suggest you to download the Word document as a stream from the Azure blob storage and perform any manipulation in the Word document. Then upload the saved Word document stream to Azure blob storage.
To download and upload a file to Azure Blob Storage in C#, you can use the Azure.Storage.Blobs package provided by Microsoft or else you can use any approach to download and upload a file as stream in blob storage to work with our DocIO library. Please refer the below code snippet to download and upload Word document as stream in Azure blob storage,
// Replace these values with your own
string connectionString = "<your_connection_string>";
string containerName = "<your_container_name>";
string blobName = "<your_blob_name>";
// Create a BlobServiceClient object using the connection string
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
// Get a reference to the blob container
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);
// Get a reference to the blob
BlobClient blobClient = containerClient.GetBlobClient(blobName);
// Download the blob as a stream
var response = await blobClient.DownloadAsync();
Stream stream = response.Value.Content;
// Open the Word document using stream
using (WordDocument document = new WordDocument(stream, Syncfusion.DocIO.FormatType.Automatic))
//Perform any operation.
//Save the Word document as memory stream.
using (MemoryStream memoryStream = new MemoryStream())
//Upload the MemoryStream to the blob.
Also refer our documentation link to know more about download files from azure blob storage,
If this post is helpful, please consider accepting it as the solution so that other members can locate it more quickly.