I have a simple C# console project that it is working with S3 Bucket and s3 objects. It is very simple project and I can find an object and reading it with AmazonS3Client.
I use this reference for working :
- AWSSDK.Core
- AWSSDK.S3
for example this function is apart of my project:
public static string GetSpecialObject(string FileName, string BucketName)
{
AmazonS3Client client = new AmazonS3Client(Amazon.RegionEndpoint.EUWest1);
// Create a GetObject request
GetObjectRequest request = new GetObjectRequest
{
BucketName = BucketName,
Key = FileName
};
using (GetObjectResponse response = client.GetObject(request))
{
using (StreamReader reader = new StreamReader(response.ResponseStream))
{
string contents = reader.ReadToEnd();
return contents;
}
}
}
As you see it is finding a file in bucket and I can return the value of file.
What is the problem ?
I created a AWS-Lambda Project (AWS-Lambda Function) and I am trying to use GetSpecialObject function there. (.Net Core 2)
I published my new project with AWS Toolkit on AWS but when I run it with Invoke button,I see this error :
"errorType": "MissingMethodException", "errorMessage": "Method not found: 'System.Collections.Generic.IList
1<System.String> Amazon.Runtime.SharedInterfaces.ICoreAmazonS3.GetAllObjectKeys(System.String, System.String, System.Collections.Generic.IDictionary
2)'.", "stackTrace": [ "at App.AWSFileClass..ctor(String accessKey, String secret, String bucket)", ......" ] }
It seems we can not use this class (AmazonS3Client) for AWS-Lambda service. I googled a lot about it. I figure-out there are some libraries for Amazon S3 that we can add in Nuget and names are :
- Amazon.S3
- AWSSDK.Core
But these library are very weak.
1 - Is there anyway to use AmazonS3Client class in AWS Lambda(.net core 2) ?
OR
2 - Is there anyway to give me a suggestion for working with S3Client class for reading an s3object ?