//
        // GET: /S3Object/
        public ActionResult Index(string prefix = "", int maxKeys = 100)
        {
            ViewBag.prefix = prefix;
              ViewBag.maxKeys = maxKeys;

              var list = new Amazon.S3.Model.ListObjectsRequest();
              list.WithBucketName(WebConfigurationManager.AppSettings["UploadBucket"]);
              if (!String.IsNullOrWhiteSpace(prefix))
              {
            list.WithPrefix(prefix);
              }

              list.WithMaxKeys(maxKeys);

              var response = s3.ListObjects(list);

              return View(response.S3Objects.Select(e => new S3Object
            {
              Key = e.Key,
              Size = e.Size,
              LastModified = e.LastModified
            }));
        }
        public ActionResult BulkDeleteConfirmed(string prefix = "", int maxKeys = 100)
        {
            if (!String.IsNullOrWhiteSpace(prefix))
              {
            ViewBag.prefix = prefix;
            ViewBag.maxKeys = maxKeys;

            var list = new Amazon.S3.Model.ListObjectsRequest();
            list.WithBucketName(WebConfigurationManager.AppSettings["UploadBucket"]);
            if (!String.IsNullOrWhiteSpace(prefix))
            {
              list.WithPrefix(prefix);
            }

            list.WithMaxKeys(maxKeys);

            var keys = s3.ListObjects(list).S3Objects.Select(e => new Amazon.S3.Model.KeyVersion(e.Key)).ToArray();

            var bulkDelete = new Amazon.S3.Model.DeleteObjectsRequest();
            bulkDelete.WithBucketName(WebConfigurationManager.AppSettings["UploadBucket"]);
            bulkDelete.WithKeys(keys);
            s3.DeleteObjects(bulkDelete);
              }

              return RedirectToAction("Index", new { prefix = prefix, maxKeys = maxKeys });
        }
        //
        // GET: /S3Object/Edit/5
        public ActionResult Edit(string id = null, string prefix = "", int maxKeys = 100)
        {
            ViewBag.prefix = prefix;
              ViewBag.maxKeys = maxKeys;

              var list = new Amazon.S3.Model.ListObjectsRequest();
              list.WithBucketName(WebConfigurationManager.AppSettings["UploadBucket"]);
              list.WithPrefix(id);

              var s3Objects = s3.ListObjects(list).S3Objects;
              if (s3Objects.Count == 0)
              {
            return HttpNotFound();
              }

              var get = new Amazon.S3.Model.GetObjectRequest();
              get.WithBucketName(WebConfigurationManager.AppSettings["UploadBucket"]);
              get.WithKey(s3Objects[0].Key);

              var response = s3.GetObject(get);

              S3Object modelObject = new S3Object
              {
            Key = s3Objects[0].Key,
            Size = s3Objects[0].Size,
            LastModified = s3Objects[0].LastModified,
            ContentType = response.ContentType
              };

              return View(modelObject);
        }
        //
        // GET: /S3Object/BulkDelete
        public ActionResult BulkDelete(string prefix = "", int maxKeys = 100)
        {
            ViewBag.prefix = prefix;
              ViewBag.maxKeys = maxKeys;

              var list = new Amazon.S3.Model.ListObjectsRequest();
              list.WithBucketName(WebConfigurationManager.AppSettings["UploadBucket"]);
              if (!String.IsNullOrWhiteSpace(prefix))
              {
            list.WithPrefix(prefix);
              }

              list.WithMaxKeys(maxKeys);

              var s3Objects = s3.ListObjects(list);
              List<S3Object> modelObjects = new List<S3Object>(s3Objects.S3Objects.Count);

              foreach (var s3Object in s3Objects.S3Objects)
              {
            modelObjects.Add(new S3Object
            {
              Key = s3Object.Key,
              Size = s3Object.Size,
              LastModified = s3Object.LastModified
            });
              }

              return View(modelObjects);
        }