protected override string SerializeInternal(IEnumerable <Bucket> bucketList)
        {
            dynamic builder = new DynamicXmlBuilder();

            builder.Declaration();
            builder.ListAllMyBucketsResult(new { xmlns = "http://s3.amazonaws.com/doc/2006-03-01/" },
                                           DynamicXmlBuilder.Fragment(list =>
            {
                list.Owner(DynamicXmlBuilder.Fragment(owner =>
                {
                    owner.ID("id");
                    owner.DisplayName("name");
                }));

                list.Buckets(DynamicXmlBuilder.Fragment(buckets =>
                {
                    foreach (var bucketItem in bucketList)
                    {
                        var item = bucketItem;
                        buckets.Bucket(DynamicXmlBuilder.Fragment(bucket =>
                        {
                            bucket.Name(item.Id);
                            bucket.CreationDate(item.CreationDate.ToUTC());
                        }));
                    }
                }));
            }));

            var result = builder.ToString(false);

            return(result);
        }
        protected override string SerializeInternal(DeleteRequest model)
        {
            dynamic builder = new DynamicXmlBuilder();

            builder.Declaration();
            builder.DeleteResult(new { xmlns = "http://s3.amazonaws.com/doc/2006-03-01/" },
                                 DynamicXmlBuilder.Fragment(deleteResult =>
            {
                deleteResult.Deleted(DynamicXmlBuilder.Fragment(deleted => { deleted.Key(model.Object.Key); }));
            }));

            var result = builder.ToString(false);

            return(result);
        }
        protected override string SerializeInternal(S3ObjectSearchResponse searchResponse)
        {
            dynamic builder = new DynamicXmlBuilder();

            builder.Declaration();
            builder.ListBucketResult(new { xmlns = "http://s3.amazonaws.com/doc/2006-03-01/" },
                                     DynamicXmlBuilder.Fragment(list =>
            {
                list.Name(searchResponse.BucketName);
                list.Prefix(searchResponse.Prefix);
                list.Marker(searchResponse.Marker);
                if (searchResponse.MaxKeys.HasValue)
                {
                    list.MaxKeys(searchResponse.MaxKeys.Value);
                }
                //list.MaxKeys(searchResponse.MaxKeys.HasValue ? searchResponse.MaxKeys.Value : int.MaxValue);
                list.IsTruncated(XmlConvert.ToString(searchResponse.IsTruncated));
                foreach (var s3Object in searchResponse.S3Objects)
                {
                    var o = s3Object;
                    list.Contents(DynamicXmlBuilder.Fragment(contents =>
                    {
                        contents.Key(o.Key);
                        contents.LastModified(o.CreationDate.ToUTC());
                        contents.ETag($"\"{o.ContentMD5}\"");
                        contents.Size(o.Size);
                        contents.StorageClass("STANDARD");
                        contents.Owner(DynamicXmlBuilder.Fragment(owner =>
                        {
                            owner.ID("id");
                            owner.DisplayName("name");
                        }));
                    }));
                }

                foreach (var prefix in searchResponse.Prefixes)
                {
                    var prefix1 = prefix;
                    list.CommonPrefixes(DynamicXmlBuilder.Fragment(cp => cp.Prefix(prefix1)));
                }
            }));

            var responseBody = builder.ToString(false);

            return(responseBody);
        }
예제 #4
0
        protected override string SerializeInternal(BucketNotFound bucketNotFound)
        {
            dynamic builder = new DynamicXmlBuilder();

            builder.Declaration();
            builder.Error(DynamicXmlBuilder.Fragment(error =>
            {
                error.Code("NoSuchBucket");
                error.Message("The specified bucket does not exist");
                error.Resource(bucketNotFound.BucketName);
                error.RequestId(1);
                error.HostId(1);
            }));

            var responseBody = builder.ToString(false);

            return(responseBody);
        }