What Amazon S3 .NET Library is most useful and efficient?

Posted by Geo on Stack Overflow See other posts from Stack Overflow or by Geo
Published on 2009-09-12T18:52:41Z Indexed on 2010/04/28 19:17 UTC
Read the original article Hit count: 288

There are two main open source .net Amazon S3 libraries.

  1. Three Sharp
  2. LitS3

I am currently using LitS3 in our MVC demo project, but there is some criticism about it. Has anyone here used both libraries so they can give an objective point of view.

Below some sample calls using LitS3:

On demo controller:

    private S3Service s3 = new S3Service()
    {
        AccessKeyID = "Thekey",
        SecretAccessKey = "testing"
    };

    public ActionResult Index()
    {
        ViewData["Message"] = "Welcome to ASP.NET MVC!";

        return View("Index",s3.GetAllBuckets());
    }

On demo view:

<% foreach (var item in Model)
   { %>
   <p>
    <%= Html.Encode(item.Name) %>
   </p>
<% } %>

EDIT 1:

Since I have to keep moving and there is no clear indication of what library is more effective and kept more up to date, I have implemented a repository pattern with an interface that will allow me to change library if I need to in the future. Below is a section of the S3Repository that I have created and will let me change libraries in case I need to:

using LitS3;

namespace S3Helper.Models
{
  public class S3Repository : IS3Repository
  {
    private S3Service _repository;
    #region IS3Repository Members

    public IQueryable<Bucket> FindAllBuckets()
    {
        return _repository.GetAllBuckets().AsQueryable();
    }

    public IQueryable<ListEntry> FindAllObjects(string BucketName)
    {
        return _repository.ListAllObjects(BucketName).AsQueryable();
    }

    #endregion

If you have any information about this question please let me know in a comment, and I will get back and edit the question.

EDIT 2: Since this question is not getting attention, I integrated both libraries in my web app to see the differences in design, I know this is probably a waist of time, but I really want a good long run solution. Below you will see two samples of the same action with the two libraries, maybe this will motivate some of you to let me know your thoughts.

WITH THREE SHARP LIBRARY:

    public IQueryable<T> FindAllBuckets<T>()
    {
        List<string> list = new List<string>();

        using (BucketListRequest request = new BucketListRequest(null))
        using (BucketListResponse response = service.BucketList(request))
        {
            XmlDocument bucketXml = response.StreamResponseToXmlDocument();
            XmlNodeList buckets = bucketXml.SelectNodes("//*[local-name()='Name']");
            foreach (XmlNode bucket in buckets)
            {
                list.Add(bucket.InnerXml);
            }
        }
        return list.Cast<T>().AsQueryable();
    }

WITH LITS3 LIBRARY:

    public IQueryable<T> FindAllBuckets<T>()
    {
        return _repository.GetAllBuckets()
            .Cast<T>()
            .AsQueryable();
    }

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about amazon-s3