0

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

2
  • what excactly is your problem? Do you receive an exception? Is the file null? Commented Jul 18, 2022 at 12:52
  • Yes I am getting file null Commented Jul 18, 2022 at 12:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.