Skip to content

Commit

Permalink
AWS-S3-Bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
KonduruKeerthi committed Jul 3, 2024
1 parent 4079536 commit 5acb176
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public async Task<IActionResult> EditDocument()
MemoryStream outputStream = new MemoryStream();
pptxDocument.Save(outputStream);

//Set the position as '0'
outputStream.Position = 0;

//Download the PowerPoint file in the browser
FileStreamResult fileStreamResult = new FileStreamResult(outputStream, "application/powerpoint");
fileStreamResult.FileDownloadName = "EditPowerPoint.pptx";
Expand All @@ -67,6 +64,12 @@ public async Task<IActionResult> EditDocument()
return Content("Error occurred while processing the file.");
}
}
/// <summary>
/// Download file from AWS S3 cloud storage
/// </summary>
/// <param name="bucketName"></param>
/// <param name="key"></param>
/// <returns></returns>
public async Task<MemoryStream> GetDocumentFromS3(string bucketName, string key)
{
//Configure AWS credentials and region
Expand Down Expand Up @@ -104,7 +107,6 @@ public async Task<MemoryStream> GetDocumentFromS3(string bucketName, string key)
throw; // or handle the exception as needed
}
}

public IActionResult Privacy()
{
return View();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public async Task<IActionResult> UploadDocument()
//Saves the PowerPoint document to MemoryStream
MemoryStream stream = new MemoryStream();
pptxDocument.Save(stream);
stream.Position = 0;

//Your AWS Storage Account bucket name
string bucketName = "your-bucket-name";
Expand All @@ -88,6 +87,13 @@ public async Task<IActionResult> UploadDocument()

return Ok("PowerPoint document uploaded to AWS S3 Storage.");
}
/// <summary>
/// Upload file to AWS S3 cloud storage
/// </summary>
/// <param name="bucketName"></param>
/// <param name="key"></param>
/// <param name="stream"></param>
/// <returns></returns>
public async Task<MemoryStream> UploadDocumentToS3(string bucketName, string key, MemoryStream stream)
{
//Configure AWS credentials and region
Expand Down Expand Up @@ -119,7 +125,6 @@ public async Task<MemoryStream> UploadDocumentToS3(string bucketName, string key
}
return stream;
}

public IActionResult Privacy()
{
return View();
Expand Down

0 comments on commit 5acb176

Please sign in to comment.