123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
-
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Text;
- using Aliyun.OSS.Util;
- namespace Aliyun.OSS
- {
-
-
-
- public class GetObjectRequest
- {
- private readonly IList<string> _matchingETagConstraints = new List<string>();
- private readonly IList<string> _nonmatchingEtagConstraints = new List<string>();
- private readonly ResponseHeaderOverrides _responseHeaders = new ResponseHeaderOverrides();
-
-
-
- public string BucketName { get; private set; }
-
-
-
- public string Key { get; private set; }
-
-
-
-
-
-
- public long[] Range { get; private set; }
-
-
-
-
-
-
-
- public DateTime? UnmodifiedSinceConstraint { get; set; }
-
-
-
-
-
-
-
- public DateTime? ModifiedSinceConstraint { get; set; }
-
-
-
-
-
- public IList<string> MatchingETagConstraints
- {
- get { return _matchingETagConstraints; }
- }
-
-
-
-
-
- public IList<string> NonmatchingETagConstraints
- {
- get { return _nonmatchingEtagConstraints; }
- }
-
-
-
- public ResponseHeaderOverrides ResponseHeaders
- {
- get { return _responseHeaders; }
- }
-
-
-
-
-
- public GetObjectRequest(string bucketName, string key)
- {
- BucketName = bucketName;
- Key = key;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public void SetRange(long start, long end)
- {
- Range = new[] { start, end };
- }
-
-
-
-
- internal void Populate(IDictionary<string, string> headers)
- {
- if (Range != null && (Range[0] >= 0 || Range[1] >= 0))
- {
- var rangeHeaderValue = new StringBuilder();
- rangeHeaderValue.Append("bytes=");
- if (Range[0] >= 0)
- rangeHeaderValue.Append(Range[0].ToString(CultureInfo.InvariantCulture));
- rangeHeaderValue.Append("-");
- if (Range[1] >= 0)
- rangeHeaderValue.Append(Range[1].ToString(CultureInfo.InvariantCulture));
- headers.Add(HttpHeaders.Range, rangeHeaderValue.ToString());
- }
- if (ModifiedSinceConstraint != null)
- {
- headers.Add(OssHeaders.GetObjectIfModifiedSince,
- DateUtils.FormatRfc822Date(ModifiedSinceConstraint.Value));
- }
- if (UnmodifiedSinceConstraint != null)
- {
- headers.Add(OssHeaders.GetObjectIfUnmodifiedSince,
- DateUtils.FormatRfc822Date(UnmodifiedSinceConstraint.Value));
- }
- if (_matchingETagConstraints.Count > 0)
- {
- headers.Add(OssHeaders.GetObjectIfMatch,
- OssUtils.JoinETag(_matchingETagConstraints));
- }
- if (_nonmatchingEtagConstraints.Count > 0)
- {
- headers.Add(OssHeaders.GetObjectIfNoneMatch,
- OssUtils.JoinETag(_nonmatchingEtagConstraints));
- }
- }
- }
- }
|