예제 #1
0
        private ObjectMetadata Deserialize(HttpResponseMessage response)
        {
            var metadata = new ObjectMetadata();

            foreach (var header in response.Headers)
            {
                if (header.Key.StartsWith(OssHeaders.OssUserMetaPrefix, false, CultureInfo.InvariantCulture))
                {
                    // The key of user in the metadata should not contain the prefix.
                    metadata.UserMetadata.Add(header.Key.Substring(OssHeaders.OssUserMetaPrefix.Length),
                                              header.Value.FirstOrDefault());
                }
                else if (string.Equals(header.Key, HttpHeaders.ContentLength, StringComparison.InvariantCultureIgnoreCase))
                {
                    // Content-Length. Parse should not fail.
                    metadata.ContentLength = long.Parse(header.Value.FirstOrDefault(), CultureInfo.InvariantCulture);
                }
                else if (string.Equals(header.Key, HttpHeaders.ETag, StringComparison.InvariantCultureIgnoreCase))
                {
                    metadata.ETag = OssUtils.TrimETag(header.Value.FirstOrDefault());
                }
                else if (string.Equals(header.Key, HttpHeaders.LastModified, StringComparison.InvariantCultureIgnoreCase))
                {
                    metadata.LastModified = DateUtils.ParseRfc822Date(header.Value.FirstOrDefault());
                }
                else
                {
                    // Treat the other headers just as strings.
                    metadata.AddHeader(header.Key, header.Value);
                }
            }
            return(metadata);
        }
        public ObjectMetadata Deserialize(HttpResponseMessage response)
        {
            ObjectMetadata metadata = new ObjectMetadata();

            foreach (KeyValuePair <string, IEnumerable <string> > header in response.Headers)
            {
                if (header.Key.StartsWith("x-oss-meta-", false, CultureInfo.InvariantCulture))
                {
                    metadata.UserMetadata.Add(header.Key.Substring("x-oss-meta-".Length), header.Value.First());
                }
                else
                {
                    if (string.Equals(header.Key, "Content-Length", StringComparison.InvariantCultureIgnoreCase))
                    {
                        metadata.ContentLength = long.Parse(header.Value.First(), CultureInfo.InvariantCulture);
                        continue;
                    }
                    if (string.Equals(header.Key, "ETag", StringComparison.InvariantCultureIgnoreCase))
                    {
                        metadata.ETag = OssUtils.TrimETag(header.Value.First());
                        continue;
                    }
                    if (string.Equals(header.Key, "Last-Modified", StringComparison.InvariantCultureIgnoreCase))
                    {
                        metadata.LastModified = DateUtils.ParseRfc822Date(header.Value.First());
                        continue;
                    }
                    metadata.AddHeader(header.Key, header.Value);
                }
            }
            return(metadata);
        }
예제 #3
0
        public MultipartUploadResult Deserialize(HttpResponseMessage response)
        {
            MultipartUploadResult result = new MultipartUploadResult();

            if (response.Headers.ETag.Tag != "")
            {
                result.ETag = OssUtils.TrimETag(response.Headers.ETag.Tag);
            }
            return(result);
        }
        public PutObjectResult Deserialize(HttpResponseMessage response)
        {
            PutObjectResult result = new PutObjectResult();

            if (response.Headers.ETag.Tag != "")
            {
                result.ETag = OssUtils.TrimETag(response.Headers.ETag.Tag);
            }
            return(result);
        }