Skip to content

Commit 26464e6

Browse files
authored
Merge pull request #92 from liangchaoboy/examples
Examples
2 parents 8ae3ce8 + 5b15587 commit 26464e6

File tree

12 files changed

+146
-18
lines changed

12 files changed

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

examples/ListDemo.cs

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

examples/copy.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
53
using System.Threading.Tasks;
64
using Qiniu.RS;
75
using Qiniu.RPC;

examples/delete.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
53
using System.Threading.Tasks;
64
using Qiniu.RS;
75
using Qiniu.RPC;

examples/download.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
53
using System.Threading.Tasks;
64
using Qiniu.RS;
75

examples/fops.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Qiniu.RS;
22
using System;
33
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
64
using System.Threading.Tasks;
75

86
namespace ConsoleDemo

examples/move.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
53
using System.Threading.Tasks;
64
using Qiniu.RS;
75
using Qiniu.RPC;

examples/stat.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
53
using System.Threading.Tasks;
64
using Qiniu.RS;
75
using Qiniu.RPC;

examples/upload_callback.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
53
using System.Threading.Tasks;
64
using Qiniu.Auth;
75
using Qiniu.IO;

0 commit comments

Comments
 (0)