I successfully downloaded the file with the help of filesaver.js.
var out = doc.getZip().generate({
type: "blob",
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
}) //Output the document using Data-URI
console.log(out);
saveAs(out,"Details.docx");
In out console I am getting object which contain size, Type.
How to save this downloaded file to AWS s3 Bucket by using ASP.NET MVC
how to call the file object to the controller
public ContentResult UploadDocument()
{
string result = "";
try
{
int fileCount = Request.Files.Count;
HttpPostedFileBase PostedFile = Request.Files[0];
string path = "Test" + "_" + PostedFile.FileName;
using (IAmazonS3 s3client = new AmazonS3Client(_awsAccessKey, _awsSecretKey, RegionEndpoint.USEast1))
{
PutObjectRequest putObjectRequest = new PutObjectRequest
{
BucketName = _bucketName,
CannedACL = S3CannedACL.PublicRead,
Key = string.Format("FolderName/" + path),
InputStream = PostedFile.InputStream
};
s3client.PutObject(putObjectRequest);
}
result = "Success";
}
catch(Exception ex)
{
result = ex.Message;
}
return Content(result);
}
I am getting Request.Files.Count null in the controller