Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

18 Comments

  1. Hi Mukesh,
    How can we check if the file uploaded properly before we move on to the next thing? Let’s say we have to perform a certain task after uploading. But need to make sure the file is uploaded correctly before doing so. How should we do that?

      1. Hi,
        I am getting following error once I delete the local user profile aws config
        System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
        —> Amazon.Runtime.AmazonClientException: No RegionEndpoint or ServiceURL configured

        How can we avoid using local config files ? I am using asp.net core application

        1. AWS .NET SDK expects the Access Key, and Secret Key to be stored in one of the following.
          1. CLI Profiles (under your user folder /.aws/credentials)
          2. Secrets.json
          3. Environment Variables.

          If you delete the CLI Profile, the SDK would not be able to connect to AWS services. To fix this, you must ensure that the credentials are updated in a secrets.json or Environement Variable. (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html). Usually for containerized deployments, ENV variable is a better option given that you do it securely.

  2. Nice well written document.

    Instead of injecting the IAmazonS3 interface into the constructor of the controller, I think you can use:

    [HttpPost(“create”)]
    public async Task CreateBucketAsync(string bucketName, [FromServices] IAmazonS3 s3Client)
    var bucketExists = await s3Client.DoesS3BucketExistAsync(bucketName);

  3. Great example, but when I deploy it to lambda it doesn’t work, just returns a corrupt file are there any configurations required?

  4. I get this error while trying to upload a file.
    Failed to fetch.
    Possible Reasons:

    CORS
    Network Failure
    URL scheme must be “http” or “https” for CORS request.

    Can you help?

    1. Try changing the port number. If you’re using VS code, you terminal will have two different port numbers shown. You can try both to see which one works. You should use an external browser like Google chrome not the inbuilt browser in Vs code

  5. GREAT. But I’m having an error.
    Can you help me with this?
    Error 500,Amazon.Runtime.AmazonServiceException: Unable to get IAM security credentials from EC2 Instance Metadata Service.

  6. Trying to test the code out using LocalStack, but it seems to barf. Defining the following in appsettings.json

    “AWS”: {
    “ServiceUrl”: “http: //localhost:4566”
    }

    does not seem to work either