@@ -29,19 +29,23 @@ public enum FileHandle
2929 /// <summary>
3030 /// 删除delete
3131 /// </summary>
32- DELETE
32+ DELETE ,
33+ /// <summary>
34+ /// 抓取资源fetch
35+ /// </summary>
36+ FETCH
3337 }
3438
3539 /// <summary>
36- /// 资源存储客户端,提供对文件的查看(stat),移动(move),复制(copy),删除(delete)操作
40+ /// 资源存储客户端,提供对文件的查看(stat),移动(move),复制(copy),删除(delete), 抓取资源(fetch) 操作
3741 /// 以及与这些操作对应的批量操作
3842 /// </summary>
39- public class RSClient : QiniuAuthClient
43+ public class RSClient : QiniuAuthClient
4044 {
41- private static string [ ] OPS = new string [ ] { "stat" , "move" , "copy" , "delete" } ;
45+ private static string [ ] OPS = new string [ ] { "stat" , "move" , "copy" , "delete" , "fetch" } ;
4246
43- public RSClient ( Mac mac = null )
44- : base ( mac )
47+ public RSClient ( Mac mac = null )
48+ : base ( mac )
4549 {
4650 }
4751
@@ -73,6 +77,16 @@ private CallRet op2 (FileHandle op, EntryPathPair pair)
7377 OPS [ ( int ) op ] ,
7478 Base64URLSafe . Encode ( pair . URISrc ) ,
7579 Base64URLSafe . Encode ( pair . URIDest ) ) ;
80+ return Call ( url ) ;
81+ }
82+
83+ private CallRet opFetch ( FileHandle op , string fromUrl , EntryPath entryPath )
84+ {
85+ string url = string . Format ( "{0}/{1}/{2}/to/{3}" ,
86+ Config . RS_HOST ,
87+ OPS [ ( int ) op ] ,
88+ Base64URLSafe . Encode ( fromUrl ) ,
89+ Base64URLSafe . Encode ( entryPath . URI ) ) ;
7690 return Call ( url ) ;
7791 }
7892
@@ -125,6 +139,17 @@ public CallRet Copy (EntryPathPair pathPair)
125139 return op2 ( FileHandle . COPY , pathPair ) ;
126140 }
127141
142+ /// <summary>
143+ /// 抓取资源
144+ /// </summary>
145+ /// <param name="fromUrl">需要抓取的文件URL</param>
146+ /// <param name="entryPath">目标entryPath</param>
147+ /// <returns>见<see cref="CallRet">CallRet</see></returns>
148+ public CallRet Fetch ( string fromUrl , EntryPath entryPath )
149+ {
150+ return opFetch ( FileHandle . FETCH , fromUrl , entryPath ) ;
151+ }
152+
128153 /// <summary>
129154 /// 获取一元批操作http request Body
130155 /// </summary>
@@ -168,11 +193,11 @@ OPS [(int)op],
168193 Base64URLSafe . Encode ( keys [ keys . Length - 1 ] . URISrc ) ,
169194 Base64URLSafe . Encode ( keys [ keys . Length - 1 ] . URIDest ) ) ;
170195 return sb . Append ( litem ) . ToString ( ) ;
171- }
172-
173- private CallRet batch ( string requestBody )
174- {
175- return CallWithBinary ( Conf . Config . RS_HOST + "/batch" , "application/x-www-form-urlencoded" , StreamEx . ToStream ( requestBody ) , requestBody . Length ) ;
196+ }
197+
198+ private CallRet batch ( string requestBody )
199+ {
200+ return CallWithBinary ( Conf . Config . RS_HOST + "/batch" , "application/x-www-form-urlencoded" , StreamEx . ToStream ( requestBody ) , requestBody . Length ) ;
176201 }
177202
178203 /// <summary>
0 commit comments