using COSXML.Common; using System; namespace COSXML.Model.Object { public sealed class GetObjectBytesRequest : ObjectRequest { /// /// 下载进度回调 /// private COSXML.Callback.OnProgressCallback progressCallback; public GetObjectBytesRequest(string bucket, string key) : base(bucket, key) { this.method = CosRequestMethod.GET; } /// /// 下载进度回调 /// /// public void SetCosProgressCallback(COSXML.Callback.OnProgressCallback progressCallback) { this.progressCallback = progressCallback; } internal COSXML.Callback.OnProgressCallback GetCosProgressCallback() { return progressCallback; } /// /// 下载内容范围 /// /// /// public void SetRange(long start, long end) { if (start < 0) { return; } if (end < start) { end = -1; } SetRequestHeader(CosRequestHeaderKey.RANGE, String.Format("bytes={0}-{1}", start, (end == -1 ? "" : end.ToString()))); } /// /// 下载内容的起始偏移量 /// /// public void SetRange(long start) { SetRange(start, -1); } /// /// 下载特定版本的对象 /// /// public void SetVersionId(string versionId) { if (versionId != null) { SetQueryParameter(CosRequestHeaderKey.VERSION_ID, versionId); } } } }