123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using COSXML.CosException;
- using COSXML.Common;
- using COSXML.Utils;
- namespace COSXML.Model.Tag
- {
- public sealed class CopySourceStruct
- {
-
-
-
- public string appid;
-
-
-
- public string bucket;
-
-
-
- public string region;
-
-
-
- public string key;
-
-
-
- public string versionId;
-
-
-
-
-
-
-
-
- public CopySourceStruct(string appid, string bucket, string region, string key, string versionId)
- {
- this.appid = appid;
- this.bucket = bucket;
- this.region = region;
- this.key = key;
- this.versionId = versionId;
- }
-
-
-
-
-
-
-
- public CopySourceStruct(string appid, string bucket, string region, string key)
- : this(appid, bucket, region, key, null)
- {
-
- }
-
-
-
- public void CheckParameters()
- {
- if (bucket == null)
- {
- throw new CosClientException((int)CosClientError.InvalidArgument, "copy source bucket = null");
- }
- if (key == null)
- {
- throw new CosClientException((int)CosClientError.InvalidArgument, "copy source cosPath = null");
- }
-
-
-
-
- if (region == null)
- {
- throw new CosClientException((int)CosClientError.InvalidArgument, "copy source region = null");
- }
- }
-
-
-
-
- public string GetCopySouce()
- {
- if (!key.StartsWith("/"))
- {
- key = "/" + key;
- }
- StringBuilder copySource = new StringBuilder();
- copySource.Append(bucket);
- if (!String.IsNullOrEmpty(appid) && !bucket.EndsWith("-" + appid))
- {
- copySource.Append("-")
- .Append(appid);
- }
- copySource.Append(".").Append("cos").Append(".")
- .Append(region).Append(".")
- .Append("myqcloud.com")
- .Append(URLEncodeUtils.EncodePathOfURL(key));
- if (versionId != null)
- {
- copySource.Append("?versionId=").Append(versionId);
- }
- return copySource.ToString();
- }
- }
- }
|