简体   繁体   English

使用C#强烈键入对Amazon S3的访问

[英]Strongly typed access to Amazon S3 using C#

I'm currently migrating a Windows Azure application to Amazon AWS. 我目前正在将Windows Azure应用程序迁移到Amazon AWS。 In Windows Azure we used Lokad.Clout to get strongly typed access to Azure Blob Storage. 在Windows Azure中,我们使用Lokad.Clout获得对Azure Blob存储的强类型访问。 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 . 有关更详细的示例,请参阅他们的wiki

In the AWS SDK for .NET you don't get strongly typed access. 在AWS SDK for .NET中,您不会获得强类型访问权限。 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). 例如,为了实现上述目的,您必须执行ListBojects然后解析每个对象的键,以便找到键的每个单独属性(我们经常使用由多个属性组成的键)。

Is there any S3-equivalent to Lokad.Cloud for Azure? 是否有任何S3相当于Azure的Lokad.Cloud?

UPDATE: Due to the size of the objects we cannot use SimpleDB (with Simple Savant). 更新:由于对象的大小,我们不能使用SimpleDB(使用Simple Savant)。

Instead of using S3 for this, I think you want to use Amazon SimpleDB. 我认为你不想使用S3,而是想使用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#. Simple Savant是用C#编写的Amazon SimpleDB的.NET对象持久性框架。

With Simple Savant, you can save objects like this: 使用Simple Savant,您可以保存这样的对象:

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! 希望这可以帮助!

This is not something that S3 was optimised for. 这不是S3优化的东西。

You should use S3 to store your blobs and a database (SimpleDB, Sql Server etc) to 'index' your S3 storage. 您应该使用S3来存储blob和数据库(SimpleDB,Sql Server等)以“索引”您的S3存储。 Use the database to find what you are looking for, get the object from S3, make changes, then save it back. 使用数据库查找您要查找的内容,从S3获取对象,进行更改,然后将其保存回来。

我通过将Lokad.Cloud中的特定名称类从Azure移植到S3来解决这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM