1
1
using System ;
2
+ using System . IO ;
2
3
using System . Text ;
3
- using System . Collections . Generic ;
4
4
using System . Security . Cryptography ;
5
- using System . IO ;
6
- using System . IO . Compression ;
7
- using qiniu ;
8
- namespace demo
5
+ using System . Collections . Generic ;
6
+
7
+ namespace qiniu
9
8
{
10
- public class ResumbalePutEx
9
+ /// <summary>
10
+ /// 断点续传.
11
+ /// </summary>
12
+ public class ResumbleUploadEx
11
13
{
12
14
private string puttedCtxDir ;
13
15
private string fileName ;
14
16
private string puttedCtxFileName ;
15
17
private Dictionary < int , BlkputRet > puttedCtx ;
16
18
17
19
/// <summary>
18
- /// Gets the putted context .
20
+ /// 获取已上传的结果 .
19
21
/// </summary>
20
22
/// <value>The putted context.</value>
21
23
public BlkputRet [ ] PuttedCtx {
@@ -27,7 +29,7 @@ public BlkputRet[] PuttedCtx {
27
29
if ( this . puttedCtx . ContainsKey ( i ) ) {
28
30
result [ i ] = this . puttedCtx [ i ] ;
29
31
} else {
30
- this . Delete ( ) ;
32
+ this . Clear ( ) ;
31
33
return null ;
32
34
}
33
35
}
@@ -39,8 +41,8 @@ public BlkputRet[] PuttedCtx {
39
41
/// Initializes a new instance of the <see cref="demo.ResumbalePutEx"/> class.
40
42
/// </summary>
41
43
/// <param name="filename">Filename.</param>
42
- /// <param name="puttedCtxDir">Putted context dir.default set to System TempPath </param>
43
- public ResumbalePutEx ( string filename , string puttedCtxDir = null ) {
44
+ /// <param name="puttedCtxDir">断点续传上传结果持久化存放目录. 默认存放在系统临时文件夹。 </param>
45
+ public ResumbleUploadEx ( string filename , string puttedCtxDir = null ) {
44
46
if ( ! File . Exists ( filename ) ) {
45
47
throw new Exception ( string . Format ( "{0} does not exist" , filename ) ) ;
46
48
}
@@ -79,7 +81,7 @@ private Dictionary<int,BlkputRet> initloadPuttedCtx(){
79
81
}
80
82
81
83
/// <summary>
82
- /// Save this putted result to disk file.
84
+ /// 保存持久化结果至磁盘文件
83
85
/// </summary>
84
86
public void Save ( ) {
85
87
StringBuilder sb = new StringBuilder ( ) ;
@@ -91,7 +93,7 @@ public void Save(){
91
93
}
92
94
93
95
/// <summary>
94
- ///
96
+ /// 保存持久化结果至内存
95
97
/// </summary>
96
98
/// <param name="tempFileName"></param>
97
99
/// <param name="idx"></param>
@@ -102,7 +104,7 @@ public void Add(int idx, BlkputRet ret)
102
104
}
103
105
104
106
/// <summary>
105
- /// Adds the and sync .
107
+ /// 保存持久化结果至内存和文件 .
106
108
/// </summary>
107
109
/// <param name="idx">Index.</param>
108
110
/// <param name="ret">Ret.</param>
@@ -112,9 +114,9 @@ public void AddAndSave(int idx,BlkputRet ret){
112
114
}
113
115
114
116
/// <summary>
115
- /// Delete this instance.
117
+ /// 清除上传持久化结果
116
118
/// </summary>
117
- public void Delete ( ) {
119
+ public void Clear ( ) {
118
120
if ( File . Exists ( this . puttedCtxFileName ) ) {
119
121
this . puttedCtx . Clear ( ) ;
120
122
File . Delete ( this . puttedCtxFileName ) ;
@@ -138,4 +140,3 @@ private static string getFileBase64Sha1(string filename)
138
140
}
139
141
}
140
142
141
-
0 commit comments