Skip to content

Commit 5a46906

Browse files
committed
addExamples
1 parent 8ae3ce8 commit 5a46906

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed

examples/BatchDemo.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Qiniu.Conf;
6+
using Qiniu.RS;
7+
using Qiniu.RPC;
8+
using Qiniu.IO;
9+
using Qiniu.RSF;
10+
11+
namespace Qiniu.Test
12+
{
13+
class BatchDemo
14+
{
15+
public static void Main() {
16+
batchCopy()
17+
}
18+
19+
/// <summary>
20+
/// 批量复制
21+
/// </summary>
22+
/// <param name="entryPathPari"></param>
23+
/// <param name="force"></param>
24+
/// <returns></returns>
25+
26+
/// 接口说明 http://developer.qiniu.com/code/v6/api/kodo-api/rs/batch.html
27+
/// BatchMove, BatchCopy, BatchDelete, BatchStat处理相同
28+
public static void batchCopy()
29+
{
30+
//初始化AK,SK
31+
Qiniu.Conf.Config.ACCESS_KEY = "Access_Key";
32+
Qiniu.Conf.Config.SECRET_KEY = "Secret_Key";
33+
34+
RSClient target = new RSClient();
35+
36+
List<EntryPathPair> list = new List<EntryPathPair>();
37+
38+
EntryPathPair[] pathPairs = new EntryPathPair[2];
39+
40+
EntryPathPair pathPair1 = new EntryPathPair(bucketSrc, keySrc, bucketDest, keyDest);
41+
EntryPathPair pathPair2 = new EntryPathPair(bucketSrc2, keySrc2, bucketDest2, keyDest2);
42+
43+
pathPairs[0] = pathPair1;
44+
pathPairs[1] = pathPair2;
45+
46+
CallRet actual = target.BatchCopy(pathPairs, true);
47+
Console.WriteLine(actual.ToString());
48+
Console.WriteLine(actual.Response);
49+
50+
}
51+
52+
}
53+
}

examples/FetchDemo.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Qiniu.Conf;
6+
using Qiniu.RS;
7+
using Qiniu.RPC;
8+
using Qiniu.IO;
9+
using Qiniu.RSF;
10+
11+
namespace Qiniu.Test
12+
{
13+
class FetchDemo
14+
{
15+
public static void Main() {
16+
17+
fetch();
18+
}
19+
20+
/// <summary>
21+
/// 抓取资源
22+
/// </summary>
23+
/// <param name="fromUrl">需要抓取的文件URL</param>
24+
/// <param name="entryPath">目标entryPath</param>
25+
/// <returns>见<see cref="CallRet">CallRet</see></returns>
26+
27+
///接口说明:http://developer.qiniu.com/code/v6/api/kodo-api/rs/fetch.html
28+
public static void fetch() {
29+
//初始化AK,SK
30+
Qiniu.Conf.Config.ACCESS_KEY = "Access_Key";
31+
Qiniu.Conf.Config.SECRET_KEY = "Secret_Key";
32+
33+
RSClient target = new RSClient(); // TODO: 初始化为适当的值
34+
EntryPath pathPath = new EntryPath("bucketName", "saveKey"); // TODO: 初始化为适当的值
35+
CallRet actual = target.Fetch(fromUrl, pathPath);
36+
Console.WriteLine(actual.ToString());
37+
Console.WriteLine(actual.Response);
38+
}
39+
}
40+
}

examples/ListDemo.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Qiniu.Conf;
6+
using Qiniu.RS;
7+
using Qiniu.RPC;
8+
using Qiniu.IO;
9+
using Qiniu.RSF;
10+
11+
namespace Qiniu.Test
12+
{
13+
class ListDemo
14+
{
15+
public static void Main() {
16+
list();
17+
}
18+
19+
/// <summary>
20+
/// The origin Fetch interface,we recomment to use Next().
21+
/// </summary>
22+
/// <returns>
23+
/// Dump
24+
/// </returns>
25+
/// <param name='bucketName'>
26+
/// 空间名
27+
/// </param>
28+
/// <param name='prefix'>
29+
/// 匹配前缀字符
30+
/// </param>
31+
/// <param name='markerIn'>
32+
/// 上一次列举返回的位置标记,作为本次列举的起点信息,默认值为空字符串。
33+
/// </param>
34+
/// <param name='limit'>
35+
/// 本次列举的条目数,范围为1-1000,缺省值为1000。
36+
/// </param>
37+
/// 接口说明:http://developer.qiniu.com/code/v6/api/kodo-api/rs/list.html
38+
public static void list() {
39+
//初始化AK,SK
40+
Qiniu.Conf.Config.ACCESS_KEY = "Access_Key";
41+
Qiniu.Conf.Config.SECRET_KEY = "Secret_Key";
42+
43+
String bucket = "Bucket_Name";
44+
String prefix = "prefix";
45+
String markerIn = "markerIn";
46+
String limit = "limit";
47+
48+
RSFClient target = new RSFClient(bucket);
49+
DumpRet actual;
50+
actual = target.ListPrefix(bucket, prefix, markerIn, limit);
51+
foreach (DumpItem item in actual.Items)
52+
{
53+
Console.WriteLine("Key:{0},Hash:{1},Mime:{2},PutTime:{3},EndUser:{4}", item.Key, item.Hash, item.Mime, item.PutTime, item.EndUser);
54+
}
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)