Skip to content

Commit e8d661e

Browse files
author
Konduru Keerthi Konduru Ravichandra Raju
committed
AWS-S3-Bucket
1 parent ecc2df7 commit e8d661e

File tree

2 files changed

+13
-4
lines changed
  • Read-and-Save-document/Open-and-save-Word-document/AWS-S3-Bucket

2 files changed

+13
-4
lines changed

Read-and-Save-document/Open-and-save-Word-document/AWS-S3-Bucket/Open-Word-document/Open-Word-document/Controllers/HomeController.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ public async Task<IActionResult> EditDocument()
5454
MemoryStream outputStream = new MemoryStream();
5555
wordDocument.Save(outputStream, Syncfusion.DocIO.FormatType.Docx);
5656

57-
//Set the position as '0'.
58-
outputStream.Position = 0;
59-
6057
//Download the Word file in the browser
6158
FileStreamResult fileStreamResult = new FileStreamResult(outputStream, "application/msword");
6259
fileStreamResult.FileDownloadName = "EditWord.docx";
@@ -69,6 +66,12 @@ public async Task<IActionResult> EditDocument()
6966
return Content("Error occurred while processing the file.");
7067
}
7168
}
69+
/// <summary>
70+
/// Download file from AWS S3 cloud storage
71+
/// </summary>
72+
/// <param name="bucketName"></param>
73+
/// <param name="key"></param>
74+
/// <returns></returns>
7275
public async Task<MemoryStream> GetDocumentFromS3(string bucketName, string key)
7376
{
7477
//Configure AWS credentials and region

Read-and-Save-document/Open-and-save-Word-document/AWS-S3-Bucket/Save-Word-document/Save-Word-document/Controllers/HomeController.cs

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

260259
//Your AWS Storage Account bucket name
261260
string bucketName = "your-bucket-name";
@@ -268,6 +267,13 @@ public async Task<IActionResult> UploadDocument()
268267

269268
return Ok("Word document uploaded to AWS S3 Storage.");
270269
}
270+
/// <summary>
271+
/// Upload file to AWS S3 cloud storage
272+
/// </summary>
273+
/// <param name="bucketName"></param>
274+
/// <param name="key"></param>
275+
/// <param name="stream"></param>
276+
/// <returns></returns>
271277
public async Task<MemoryStream> UploadDocumentToS3(string bucketName, string key, MemoryStream stream)
272278
{
273279
//Configure AWS credentials and region

0 commit comments

Comments
 (0)