使用 C# 对 Amazon S3 进行强类型访问

发布于 2024-10-07 11:26:35 字数 737 浏览 6 评论 0原文

我目前正在将 Windows Azure 应用程序迁移到 Amazon AWS。在 Windows Azure 中,我们使用 Lokad.Clout 获得对 Azure Blob 存储的强类型访问。例如这样:

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

有关更详细的示例,请参阅他们的 wiki

在适用于 .NET 的 AWS 开发工具包中,您无法获得强类型访问权限。例如,为了实现上述目标,您必须执行 ListBojects,然后解析每个对象的键,以便找到键的每个单独属性(我们经常使用由多个属性组成的键)。

是否有任何与适用于 Azure 的 Lokad.Cloud 等效的 S3?

更新:由于对象的大小,我们无法使用 SimpleDB(与 Simple Savant)。

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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫南 2024-10-14 11:26:35

我认为您不想使用 S3,而是使用 Amazon SimpleDB。它允许您以键值对格式存储数据,并对数据运行查询。

然后,为了做你正在寻找的事情,我认为你想要的是Simple Savant

Simple Savant 是一个用 C# 编写的 Amazon SimpleDB .NET 对象持久性框架。

使用 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);

并且您可以像这样检索对象:

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

希望这会有所帮助!

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!

过期情话 2024-10-14 11:26:35

这不是 S3 优化的内容。

您应该使用 S3 来存储 Blob,并使用数据库(SimpleDB、Sql Server 等)来“索引”您的 S3 存储。使用数据库查找您要查找的内容,从 S3 获取对象,进行更改,然后将其保存回来。

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.

昔日梦未散 2024-10-14 11:26:35

我自己解决了这个问题,方法是将 Lokad.Cloud 中的那些特定名称类从 Azure 移植到 S3

I solved it myself by porting those particular name-classes in Lokad.Cloud from Azure to S3

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文