Exemple #1
0
        public List <S3Object> ObjectsFromKey(string key)
        {
            List <S3Object> s3Files = new List <S3Object>();

            try
            {
                var request = new ListObjectsRequest {
                    BucketName = AWSBucket, Prefix = key, Delimiter = @"/"
                };

                do
                {
                    var response = S3Client.ListObjects(request);
                    s3Files.AddRange(response.S3Objects);

                    if (response.IsTruncated)
                    {
                        request.Marker = response.NextMarker;
                    }
                    else
                    {
                        request = null;
                    }
                } while (request != null);
            }
            catch (Exception e)
            {
                log.Error("ObjectsFromKey", e);
            }
            return(s3Files);
        }
Exemple #2
0
        /// <summary>
        /// Gets the latest backup set item by last modified date.
        /// </summary>
        /// <returns>The latest backup set.</returns>
        private S3Object GetLatestBackupItem()
        {
            List <S3Object> objects   = new List <S3Object>();
            string          marker    = String.Empty;
            bool            truncated = true;

            while (truncated)
            {
                ListObjectsRequest request = new ListObjectsRequest()
                                             .WithBucketName(AwsConfig.BucketName)
                                             .WithPrefix(this.AwsPrefix)
                                             .WithMarker(marker);

                using (ListObjectsResponse response = S3Client.ListObjects(request))
                {
                    objects.AddRange(response.S3Objects);

                    if (response.IsTruncated)
                    {
                        marker = objects[objects.Count - 1].Key;
                    }
                    else
                    {
                        truncated = false;
                    }
                }
            }

            if (objects.Count == 0)
            {
                throw new InvalidOperationException(String.Concat("There was no backup set found for catalog \"", this.Target.CatalogName, "\"."));
            }

            return(objects.OrderByDescending(o => DateTime.Parse(o.LastModified, CultureInfo.InvariantCulture)).First());
        }
Exemple #3
0
        public override IList <AsimovVersion> GetAvailableVersions(PackageInfo packageInfo)
        {
            var prefix = packageInfo.SourceRelativePath != null ?
                         $"{Prefix}/{packageInfo.SourceRelativePath}" :
                         Prefix;
            var objects = S3Client.ListObjects(Bucket, prefix);

            return(objects.S3Objects.Select(x => ParseVersion(x.Key, x.LastModified)).Where(x => x != null).ToList());
        }