AWS-how to CRUD in S3

I recently started studying AWS, and I'm feeling totally lost about the meaning of some things, how they work, and what their contexts are for the application.

For example Keys, buckets, ARN ... Things like that.

Could someone tell me the meaning of these and exemplify some CRUD operations directly within AWS S3 ?

With the code below I can log in and copy things from the input (inbox) to the output box (outbox) but nothing more than that.

public class FileBatch
{

    private readonly string[] _supportedImageTypes = new string[] { ".png", ".jpg", ".jpeg" };
    private readonly AmazonS3Client _s3Client;

    public FileBatch()
    {
        AmazonS3Config config = new AmazonS3Config();



        _s3Client = new AmazonS3Client(
            "00000000000000000000", //ID_Access
            "0000000000000000000000000000000000000000", //Key_Access
            config
        );


    }

    public async Task OcrHandler(S3Event s3Event, ILambdaContext context)
    {


 foreach (var record in s3Event.Records)
        {

            if (!Regex.IsMatch(record.S3.Object.Key, @"inbox/.*"))
            {
                continue;
            }

Console.WriteLine(
                $"A imagem '{record.S3.Bucket.Name}:{record.S3.Object.Key}' será processada e copiada para a caixa de saída");

            var outputKey = record.S3.Object.Key.Replace("inbox/", "outbox/");

            CopyObjectRequest request = new CopyObjectRequest
            {
                SourceBucket = record.S3.Bucket.Name,
                SourceKey = record.S3.Object.Key,
                DestinationBucket = record.S3.Bucket.Name,
                DestinationKey = outputKey
            };
            CopyObjectResponse response = await _s3Client.CopyObjectAsync(request);

        }
    }

I think I ended up discovering the documentation I needed to do the simplest operations, but I don't know how to use it right...

Https://docs.aws.amazon.com/sdkfornet1/latest/apidocs/html/T_Amazon_S3_AmazonS3Client.htm


I believe this is the way to create things inside AWS folders

// Create a client
AmazonS3Client client = new AmazonS3Client();

// Create a PutObject request
PutObjectRequest request = new PutObjectRequest
{
    BucketName = "SampleBucket",
    Key = "Item1",
};

using (FileStream stream = new FileStream("contents.txt", FileMode.Open))
{
    request.InputStream = stream;

    // Put object
    PutObjectResponse response = client.PutObject(request);
}
Author: Gunblades, 2018-11-23

1 answers

The answer to your question is not so simple and may cause an extensive discussion about how best to model/design / design a software solution to utilize an object store structure (e.g. AWS S3, AWS Glazier). So the following is my interpretation of how you could follow your development by revisiting some concepts and judging the best for your scenario.

AWS S3 is a software solution for object storage from AWS , which it uses AWS-specific concepts because it is a proprietary AWS Solution.

Relational databases (e.g. Oracle DB, Mysql DB) model their data using concepts of tables and relationships.

According to the English Wikipedia CRUD means:

CRUD (acronym for Create, Read, Update and Delete) are the four basic operations (creation, query, update, and destruction of data) used in relational databases (RDBMS) provided to users of the system.

The English version has a more interesting discussion about REST ( https://en.wikipedia.org/wiki/Create,_read,_update_and_delete ), S3 implements a REST api that can be interpreted as CRUD.

Following the English definitions, CRUD is originally used as a software solution to access data within a relational database.

However S3 is not relational. Eventually you could use a CRUD approach with S3, however there are richer alternatives of abstraction.

On the possibilities of what you can do with S3, AWS documentation is extensive and of excellent quality, I suggest you start by https://aws.amazon.com/pt/s3/getting-started /

 3
Author: Rafael Gorski, 2019-05-08 21:16:09