user2247527
user2247527

Reputation: 1

AWS Credentials issue while access S3 bucket in C#

I set all my profile in my computer which is working in my local machine, when i try to access in aws EC2 instance it is not working, both machine "defult" profile configured, i am getting null in "basicProfile" variable

may i know what is the reason? please me to solve sooner.

 CredentialProfile basicProfile;
AWSCredentials awsCredentials;
var sharedFile = new SharedCredentialsFile();

  if (sharedFile.TryGetProfile("default", basicProfile) && AWSCredentialsFactory.TryGetAWSCredentials(basicProfile, sharedFile, awsCredentials))
    {
        var client = new AmazonS3Client(awsCredentials);
        var response = client.PutObject(request);
        if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

Upvotes: 0

Views: 91

Answers (0)

Related Questions