none
How to integrate aws s3 bucket through MFA using asp.net mvc c# programmatically RRS feed

  • Question

  • I am trying to add MFA (Multi Factor Authentication) in my application, where i am going to store object in aws S3 buckets. Please provide any sample code for authenticate the amazon aws service through MFA while uploading the objects/image to s3 bucket using asp.net mvc c#.

    Here is the below working code snippet without MFA,

    var awsCredentials = new BasicAWSCredentials(accessKey, secretKey);

    _client = new AmazonS3Client(awsCredentials, Amazon.RegionEndpoint.USEast1);

    var putRequest = new PutObjectRequest
    {
    BucketName = ConfigurationManager.AppSettings["S3BucketName"],
    Key = fileName,
    FilePath = localFilePath,
    ContentType = "image/" + Path.GetExtension(fileName),
    CannedACL = S3CannedACL.PublicRead
    };
    var req = JsonConvert.SerializeObject(putRequest);
    Thanks,
    • Moved by CoolDadTx Thursday, March 21, 2019 1:48 PM ASP.NET related
    Thursday, March 21, 2019 10:02 AM

All replies