diff --git a/Qiniu/RS/RSClient.cs b/Qiniu/RS/RSClient.cs index 20b6ca74..74df557d 100644 --- a/Qiniu/RS/RSClient.cs +++ b/Qiniu/RS/RSClient.cs @@ -80,6 +80,24 @@ OPS [(int)op], return Call(url); } + + /// + /// + /// + /// + /// + /// + private CallRet op2(FileHandle op, EntryPathPair pair, bool force) + { + + string url = string.Format("{0}/{1}/{2}/{3}/force/{4}", + Config.RS_HOST, + OPS[(int)op], + Base64URLSafe.Encode(pair.URISrc), + Base64URLSafe.Encode(pair.URIDest), force); + return Call(url); + } + private CallRet opFetch(FileHandle op, string fromUrl, EntryPath entryPath) { string url = string.Format("{0}/{1}/{2}/to/{3}", @@ -126,6 +144,21 @@ public CallRet Move (EntryPathPair pathPair) return op2 (FileHandle.MOVE, pathPair); } + + /// + /// 移动文件 + /// + /// 文件所属的源空间名称 + /// 源key + /// 目标空间名称 + /// 目标key + /// 强制覆盖 + /// CallRet + public CallRet Move(EntryPathPair pathPair, bool force) + { + return op2(FileHandle.MOVE, pathPair, force); + } + /// /// 复制 /// @@ -139,6 +172,22 @@ public CallRet Copy (EntryPathPair pathPair) return op2 (FileHandle.COPY, pathPair); } + /// + /// 复制 + /// + /// 文件所属的空间名称 + /// 需要复制的文件key + /// 复制至目标空间 + /// 复制的副本文件key + /// 复制是否强制覆盖目标文件 + /// CallRet + public CallRet Copy(EntryPathPair pathPair, bool force) + { + + return op2(FileHandle.COPY, pathPair, force); + + } + /// /// 抓取资源 /// @@ -195,6 +244,33 @@ OPS [(int)op], return sb.Append (litem).ToString (); } + /// + /// + /// + /// + /// + /// + /// + private string getBatchOp_2(FileHandle op, EntryPathPair[] keys, bool force) + { + if (keys.Length < 1) + return string.Empty; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < keys.Length - 1; i++) + { + string item = string.Format("op=/{0}/{1}/{2}/force/{3}/&", + OPS[(int)op], + Base64URLSafe.Encode(keys[i].URISrc), + Base64URLSafe.Encode(keys[i].URIDest), force); + sb.Append(item); + } + string litem = string.Format("op=/{0}/{1}/{2}/force/{3}", OPS[(int)op], + Base64URLSafe.Encode(keys[keys.Length - 1].URISrc), + Base64URLSafe.Encode(keys[keys.Length - 1].URIDest), force); + return sb.Append(litem).ToString(); + } + + private CallRet batch(string requestBody) { return CallWithBinary(Conf.Config.RS_HOST + "/batch", "application/x-www-form-urlencoded", StreamEx.ToStream(requestBody), requestBody.Length); @@ -241,6 +317,18 @@ public CallRet BatchMove (EntryPathPair[] entryPathPairs) return batch (requestBody); } + /// + /// batch + /// + /// + /// + /// + public CallRet BatchMove(EntryPathPair[] entryPathPairs, bool force) + { + string requestBody = getBatchOp_2(FileHandle.MOVE, entryPathPairs, force); + return batch(requestBody); + } + /// /// /// @@ -252,6 +340,18 @@ public CallRet BatchCopy (EntryPathPair[] entryPathPari) return batch (requestBody); } + /// + /// 批量复制 + /// + /// + /// + /// + public CallRet BatchCopy(EntryPathPair[] entryPathPari, bool force) + { + string requestBody = getBatchOp_2(FileHandle.COPY, entryPathPari, force); + return batch(requestBody); + } + /// /// 批量删除 ///