Skip to content

Commit 52904d3

Browse files
author
Konduru Keerthi Konduru Ravichandra Raju
committed
Azure-Blob-Storage
1 parent cc6ac2a commit 52904d3

File tree

2 files changed

+12
-5
lines changed
  • Read-and-Save-document/Open-and-save-Word-document/Azure-Blob-Storage

2 files changed

+12
-5
lines changed

Read-and-Save-document/Open-and-save-Word-document/Azure-Blob-Storage/Open-Word-document/Open-Word-document/Controllers/HomeController.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ public async Task<IActionResult> EditDocument()
6262
MemoryStream outputStream = new MemoryStream();
6363
wordDocument.Save(outputStream, Syncfusion.DocIO.FormatType.Docx);
6464

65-
//Set the position as '0'
66-
outputStream.Position = 0;
67-
6865
//Download the Word file in the browser
6966
FileStreamResult fileStreamResult = new FileStreamResult(outputStream, "application/msword");
7067
fileStreamResult.FileDownloadName = "EditWord.docx";
@@ -78,6 +75,12 @@ public async Task<IActionResult> EditDocument()
7875
return Content("Error occurred while processing the file.");
7976
}
8077
}
78+
/// <summary>
79+
/// Download file from Azure Blob cloud storage
80+
/// </summary>
81+
/// <param name="bucketName"></param>
82+
/// <param name="key"></param>
83+
/// <returns></returns>
8184
public async Task<MemoryStream> GetDocumentFromAzure(string connectionString, string containerName, string blobName)
8285
{
8386
try
@@ -100,7 +103,6 @@ public async Task<MemoryStream> GetDocumentFromAzure(string connectionString, st
100103
throw; // or handle the exception as needed
101104
}
102105
}
103-
104106
public IActionResult Privacy()
105107
{
106108
return View();

Read-and-Save-document/Open-and-save-Word-document/Azure-Blob-Storage/Save-Word-document/Save-Word-document/Controllers/HomeController.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ public async Task<IActionResult> UploadDocument()
253253
//Saves the Word document to MemoryStream
254254
MemoryStream stream = new MemoryStream();
255255
document.Save(stream, FormatType.Docx);
256-
stream.Position = 0;
257256

258257
//Your Azure Storage Account connection string
259258
string connectionString = "Your_connection_string";
@@ -269,6 +268,12 @@ public async Task<IActionResult> UploadDocument()
269268

270269
return Ok("Word document uploaded to Azure Blob Storage.");
271270
}
271+
/// <summary>
272+
/// Upload file to Azure Blob cloud storage
273+
/// </summary>
274+
/// <param name="bucketName"></param>
275+
/// <param name="key"></param>
276+
/// <returns></returns>
272277
public async Task<MemoryStream> UploadDocumentToAzure(string connectionString, string containerName, string blobName, MemoryStream stream)
273278
{
274279
try

0 commit comments

Comments
 (0)