Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strongly typed access to Amazon S3 using C#

I'm currently migrating a Windows Azure application to Amazon AWS. In Windows Azure we used Lokad.Clout to get strongly typed access to Azure Blob Storage. For instance like this:

foreach(var name in storage.List(CustomerBlobName.Prefix(country))
{
  var customer = storage.GetBlob(name); // strong type, no cast!
  // do something with 'customer', snipped
}

For more detailed examples see their wiki.

In the AWS SDK for .NET you don't get strongly typed access. For instance in order to achive the above you have to execute ListBojects and then parse the key of every object in order to find the each individual property of the key (we often use keys consisting of several properties).

Is there any S3-equivalent to Lokad.Cloud for Azure?

UPDATE: Due to the size of the objects we cannot use SimpleDB (with Simple Savant).

like image 940
Yrlec Avatar asked Dec 14 '10 22:12

Yrlec


People also ask

What is the safest way to grant access to S3 bucket?

Use encryption to protect your data If your use case requires encryption for data at rest, Amazon S3 offers server-side encryption (SSE). The SSE options include SSE-S3, SSE-KMS, or SSE-C. You can specify the SSE parameters when you write objects to the bucket.

What methods can be used to grant access to an object in S3?

Grant public read access in one of these ways: Update the object's access control list (ACL) using the Amazon S3 console. Update the object's ACL using the AWS Command Line Interface (AWS CLI) Use a bucket policy that grants public read access to a specific object tag.


2 Answers

Instead of using S3 for this, I think you want to use Amazon SimpleDB. It allows you to store data in key-value pair format, and also run queries on the data.

Then, to do what you're looking for, I think what you want is Simple Savant.

Simple Savant is a .NET object-persistence framework for Amazon SimpleDB written in C#.

With Simple Savant, you can save objects like this:

var savant = new SimpleSavant(AwsAccessKeyId, AwsSecretAccessKey);
var customer = new Customer
    {Name = "Frank Berry", PhoneNumbers = new List<string> {"770-555-1234", "678-555-5678"} };
savant.Put(customer);

And you can retrieving objects like this:

 var frankId = new Guid("50a60862-09a2-450a-8b7d-5d585662990b");
 Person frank = savant.Get<Person>(frankId);  // strong type, no cast!

Hope this helps!

like image 106
BigJoe714 Avatar answered Oct 12 '22 18:10

BigJoe714


This is not something that S3 was optimised for.

You should use S3 to store your blobs and a database (SimpleDB, Sql Server etc) to 'index' your S3 storage. Use the database to find what you are looking for, get the object from S3, make changes, then save it back.

like image 21
Geoff Appleford Avatar answered Oct 12 '22 19:10

Geoff Appleford