Skip to content

Commit 7ca7378

Browse files
author
fengyunhai
committed
更新示例代码
1 parent a2d4fd7 commit 7ca7378

File tree

10 files changed

+172
-9
lines changed

10 files changed

+172
-9
lines changed

examples/App.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace QiniuDemo
1+
namespace CSharpSDKExamples
22
{
33
/// <summary>
44
/// 示例代码中的bucket,saveKey,localFile等请自行设置
@@ -59,7 +59,28 @@ static void Main(string[] args)
5959
// 文件处理+保存处理结果
6060
//PfopWithPipeline.pfopAndSave();
6161

62-
System.Console.ReadKey();
62+
// 数据处理dfop:url
63+
//DfopDemo.dfopUrl();
64+
65+
// 数据处理dfop:data
66+
//DfopDemo.dfopData();
67+
68+
// 融合CDN 缓存刷新
69+
//FusionDemo.refresh();
70+
71+
// 融合CDN 文件预取
72+
//FusionDemo.prefetch();
73+
74+
// 融合CDN 带宽
75+
//FusionDemo.bandwidth();
76+
77+
// 融合CDN 流量
78+
//FusionDemo.flux();
79+
80+
// 融合CDN 日志查询
81+
//FusionDemo.loglist();
82+
83+
System.Console.ReadLine();
6384
}
6485
}
6586
}

examples/BucketFileManagement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Qiniu.Http;
55
using System.Collections.Generic;
66

7-
namespace QiniuDemo
7+
namespace CSharpSDKExamples
88
{
99
/// <summary>
1010
/// 空间及空间文件管理

examples/DfopDemo.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using Qiniu.Util;
3+
using Qiniu.Processing;
4+
5+
namespace CSharpSDKExamples
6+
{
7+
public class DfopDemo
8+
{
9+
/// <summary>
10+
/// dfop形式1:URL
11+
/// </summary>
12+
public static void dfopUrl()
13+
{
14+
Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);
15+
Dfop dfx = new Dfop(mac);
16+
17+
string fop = "FOP"; // E.G.: "imageInfo"
18+
string url = "RES_URL";
19+
20+
var ret = dfx.dfop(fop, url);
21+
22+
if (ret.ResponseInfo.StatusCode != 200)
23+
{
24+
Console.WriteLine(ret.ResponseInfo);
25+
}
26+
Console.WriteLine(ret.Response);
27+
}
28+
29+
/// <summary>
30+
/// dfop形式2:Data
31+
/// </summary>
32+
public static void dfopData()
33+
{
34+
Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);
35+
Dfop dfx = new Dfop(mac);
36+
37+
string fop = "FOP";
38+
byte[] data = System.IO.File.ReadAllBytes("LOCAL_FILE");
39+
40+
var ret = dfx.dfop(fop, data);
41+
42+
if (ret.ResponseInfo.StatusCode != 200)
43+
{
44+
Console.WriteLine(ret.ResponseInfo);
45+
}
46+
Console.WriteLine(ret.Response);
47+
}
48+
}
49+
}

examples/FusionDemo.cs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using System;
2+
using Qiniu.Util;
3+
using Qiniu.Fusion;
4+
using Qiniu.Fusion.Model;
5+
6+
namespace CSharpSDKExamples
7+
{
8+
/// <summary>
9+
/// 融合CDN功能
10+
/// </summary>
11+
public class FusionDemo
12+
{
13+
/// <summary>
14+
/// 缓存刷新
15+
/// </summary>
16+
public static void refresh()
17+
{
18+
Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);
19+
FusionManager fusionMgr = new FusionManager(mac);
20+
21+
string[] urls = new string[] { "URL1", "URL2" };
22+
string[] dirs = new string[] { "DIR1", "DIR2" };
23+
RefreshRequest request = new RefreshRequest();
24+
request.AddUrls(urls);
25+
request.AddDirs(dirs);
26+
RefreshResult result = fusionMgr.Refresh(request);
27+
Console.WriteLine(result);
28+
}
29+
30+
/// <summary>
31+
/// 文件预取
32+
/// </summary>
33+
public static void prefetch()
34+
{
35+
Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);
36+
FusionManager fusionMgr = new FusionManager(mac);
37+
38+
string[] urls = new string[] { "URL1", "URL2" };
39+
PrefetchRequest request = new PrefetchRequest(urls);
40+
PrefetchResult result = fusionMgr.Prefetch(request);
41+
Console.WriteLine(result);
42+
}
43+
44+
/// <summary>
45+
/// 带宽
46+
/// </summary>
47+
public static void bandwidth()
48+
{
49+
Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);
50+
FusionManager fusionMgr = new FusionManager(mac);
51+
52+
BandwidthRequest request = new BandwidthRequest();
53+
request.StartDate = "START_DATE"; // "2016-09-01"
54+
request.EndDate = "END_DATE"; // "2016-09-20"
55+
request.Granularity = "GRANU"; // "day"
56+
request.Domains = "DOMAIN1;DOMAIN2"; // domains
57+
BandwidthResult result = fusionMgr.Bandwidth(request);
58+
Console.WriteLine(result);
59+
}
60+
61+
/// <summary>
62+
/// 流量
63+
/// </summary>
64+
public static void flux()
65+
{
66+
Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);
67+
FusionManager fusionMgr = new FusionManager(mac);
68+
69+
FluxRequest request = new FluxRequest();
70+
request.StartDate = "START_DATE"; // "2016-09-01"
71+
request.EndDate = "END_DATE"; // "2016-09-20"
72+
request.Granularity = "GRANU"; // "day"
73+
request.Domains = "DOMAIN1;DOMAIN2"; // domains
74+
FluxResult result = fusionMgr.Flux(request);
75+
Console.WriteLine(result);
76+
}
77+
78+
/// <summary>
79+
/// 日志查询
80+
/// </summary>
81+
public static void loglist()
82+
{
83+
Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey);
84+
FusionManager fusionMgr = new FusionManager(mac);
85+
86+
LogListRequest request = new LogListRequest();
87+
request.Day = "DAY"; // "2016-09-01"
88+
request.Domains = "DOMAIN1"; // domains
89+
LogListResult result = fusionMgr.LogList(request);
90+
Console.WriteLine(result);
91+
}
92+
}
93+
}

examples/PfopWithPipeline.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Qiniu.Http;
33
using Qiniu.Processing;
44

5-
namespace QiniuDemo
5+
namespace CSharpSDKExamples
66
{
77
public class PfopWithPipeline
88
{

examples/ResumableUpload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using Qiniu.Storage.Persistent;
44
using Qiniu.Http;
55

6-
namespace QiniuDemo
6+
namespace CSharpSDKExamples
77
{
88
public class ResumableUpload
99
{

examples/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Linq;
44
using System.Text;
55

6-
namespace QiniuDemo
6+
namespace CSharpSDKExamples
77
{
88
public class Settings
99
{

examples/SimpleDownload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Qiniu.Util;
22
using Qiniu.Storage;
33

4-
namespace QiniuDemo
4+
namespace CSharpSDKExamples
55
{
66
public class SimpleDownload
77
{

examples/SimpleUpload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Qiniu.Storage;
33
using Qiniu.Http;
44

5-
namespace QiniuDemo
5+
namespace CSharpSDKExamples
66
{
77
public class SimpleUpload
88
{

examples/UploadWithFop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Qiniu.Util;
22
using Qiniu.Storage;
33

4-
namespace QiniuDemo
4+
namespace CSharpSDKExamples
55
{
66
public class UploadWithFop
77
{

0 commit comments

Comments
 (0)