Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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();
    }
like image 604
Geo Avatar asked Sep 12 '09 18:09

Geo


People also ask

Which S3 storage class is the most cost effective for archiving data with no retrieval time requirement?

For data that does not require immediate retrieval, you can set up S3 Intelligent-Tiering to monitor and automatically move objects that aren't accessed for 180 days or more to the Deep Archive Access tier to realize up to 95% in storage cost savings. There are no retrieval charges in S3 Intelligent-Tiering.

What is S3 best used for?

Flexibility: S3 is ideal for a wide range of uses like data storage, data backup, software delivery, data archiving, disaster recovery, website hosting, mobile applications, IoT devices, and much more.

Which Amazon S3 storage classes are optimized for archival data select two?

One Zone-IA, Glacier and Glacier Deep Archive are the most appropriate Amazon S3 storage classes for long-term archival.

What Amazon S3 feature is used to categorize your objects in Amazon S3?

All objects are stored in S3 buckets and can be organized with shared names called prefixes. You can also append up to 10 key-value pairs called S3 object tags to each object, which can be created, updated, and deleted throughout an object's lifecycle.


2 Answers

Looks like the official library is now 'AWS SDK for .NET', available here: http://aws.amazon.com/sdkfornet/

Looks like it includes:

  • Code samples
  • Visual Studio integration
  • .NET library code

It supports:

  • Amazon Elastic Compute Cloud
  • Amazon Simple Storage Service
  • Amazon Virtual Private Cloud
  • Amazon SimpleDB
  • Amazon Relational Database Service
  • Amazon CloudFront
  • Amazon Simple Queue Service
  • Amazon Simple Notification Service
  • Amazon Elastic MapReduce
  • Amazon CloudWatch
  • Elastic Load Balancing
  • Auto Scaling
like image 189
Dan Esparza Avatar answered Sep 21 '22 06:09

Dan Esparza


I can chime in by saying that we have been using Affirma ThreeSharp for perhaps a year or so. I'm pretty sure the first time we were using S3 we were using Amazon's SOAP library which was certainly not as easy as Affirma's ThreeSharp.

I have also found it to be very reliable, even when doing batch work and uploading / downloading large amounts of data. Project doesn't seem to get updated that much, but then we haven't felt like it was ever in need of being updated!

Code example: Something like this will upload a file:

m_config = new ThreeSharpConfig
                           {
                               AwsAccessKeyID = Core.ConfigSettings.AmazonS3AccessKey,
                               AwsSecretAccessKey = Core.ConfigSettings.AmazonS3SecretAccessKey,
                               ConnectionLimit = 40,
                               IsSecure = true

                           };
            m_service = new ThreeSharpQuery(m_config);



 using (var request = new ObjectAddRequest(amazonS3BucketName, fileName.Replace(' ', '_')))
            {
                request.Headers.Add("x-amz-acl", "public-read-write");
                request.LoadStreamWithBytes(fileData);

                if (redirectUrl != null)
                {
                    request.RedirectUrl = redirectUrl;
                }

                using (ObjectAddResponse response = m_service.ObjectAdd(request))
                { }
            }

Edit: Amazon have now launched their own .Net library for their web services (including S3) so consequently Affirma are no longer supporting their library.
http://aws.amazon.com/sdkfornet/

like image 45
Perhentian Avatar answered Sep 21 '22 06:09

Perhentian