Esempio n. 1
0
        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 });
        }
Esempio n. 2
0
        //
        // 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
            }));
        }
Esempio n. 3
0
        //
        // 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);
        }