diff --git a/Qiniu/RS/RSClient.cs b/Qiniu/RS/RSClient.cs
index 4d3a1a04..a2d2048b 100644
--- a/Qiniu/RS/RSClient.cs
+++ b/Qiniu/RS/RSClient.cs
@@ -29,19 +29,23 @@ public enum FileHandle
///
/// 删除delete
///
- DELETE
+ DELETE,
+ ///
+ /// 抓取资源fetch
+ ///
+ FETCH
}
///
- /// 资源存储客户端,提供对文件的查看(stat),移动(move),复制(copy),删除(delete)操作
+ /// 资源存储客户端,提供对文件的查看(stat),移动(move),复制(copy),删除(delete), 抓取资源(fetch) 操作
/// 以及与这些操作对应的批量操作
///
- public class RSClient :QiniuAuthClient
+ public class RSClient : QiniuAuthClient
{
- private static string[] OPS = new string[] { "stat", "move", "copy", "delete" };
+ private static string[] OPS = new string[] { "stat", "move", "copy", "delete", "fetch" };
- public RSClient (Mac mac=null)
- : base(mac)
+ public RSClient(Mac mac = null)
+ : base(mac)
{
}
@@ -73,6 +77,16 @@ private CallRet op2 (FileHandle op, EntryPathPair pair)
OPS [(int)op],
Base64URLSafe.Encode (pair.URISrc),
Base64URLSafe.Encode (pair.URIDest));
+ return Call(url);
+ }
+
+ private CallRet opFetch(FileHandle op, string fromUrl, EntryPath entryPath)
+ {
+ string url = string.Format("{0}/{1}/{2}/to/{3}",
+ Config.RS_HOST,
+ OPS[(int)op],
+ Base64URLSafe.Encode(fromUrl),
+ Base64URLSafe.Encode(entryPath.URI));
return Call (url);
}
@@ -125,6 +139,17 @@ public CallRet Copy (EntryPathPair pathPair)
return op2 (FileHandle.COPY, pathPair);
}
+ ///
+ /// 抓取资源
+ ///
+ /// 需要抓取的文件URL
+ /// 目标entryPath
+ /// 见CallRet
+ public CallRet Fetch(string fromUrl, EntryPath entryPath)
+ {
+ return opFetch(FileHandle.FETCH, fromUrl, entryPath);
+ }
+
///
/// 获取一元批操作http request Body
///
@@ -168,11 +193,11 @@ OPS [(int)op],
Base64URLSafe.Encode (keys [keys.Length - 1].URISrc),
Base64URLSafe.Encode (keys [keys.Length - 1].URIDest));
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);
+ }
+
+ private CallRet batch(string requestBody)
+ {
+ return CallWithBinary(Conf.Config.RS_HOST + "/batch", "application/x-www-form-urlencoded", StreamEx.ToStream(requestBody), requestBody.Length);
}
///