Skip to content

Commit e83bc66

Browse files
author
fengyunhai
committed
优化dfop操作逻辑
1 parent c45dd4b commit e83bc66

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

Qiniu/Processing/Dfop.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,13 @@ public DfopResult dfop(string fop,string url)
3232
Dictionary<string, string> dfopHeaders = new Dictionary<string, string>();
3333
dfopHeaders.Add("Authorization", token);
3434

35-
CompletionHandler dfopCompletionHandler = new CompletionHandler(delegate (ResponseInfo respInfo, string response)
35+
RecvDataHandler dfopRecvDataHandler = new RecvDataHandler(delegate (ResponseInfo respInfo, byte[] respData)
3636
{
37-
if (respInfo.isOk())
38-
{
39-
dfopResult = StringUtils.jsonDecode<DfopResult>(response);
40-
}
41-
4237
dfopResult.ResponseInfo = respInfo;
43-
dfopResult.Response = response;
38+
dfopResult.ResponseData = respData;
4439
});
4540

46-
mHttpManager.postForm(dfopUrl, dfopHeaders, null, dfopCompletionHandler);
41+
mHttpManager.postFormRaw(dfopUrl, dfopHeaders, dfopRecvDataHandler);
4742

4843
return dfopResult;
4944
}
@@ -59,18 +54,13 @@ public DfopResult dfop(string fop,byte[] data)
5954
Dictionary<string, string> dfopHeaders = new Dictionary<string, string>();
6055
dfopHeaders.Add("Authorization", token);
6156

62-
CompletionHandler dfopCompletionHandler = new CompletionHandler(delegate (ResponseInfo respInfo, string response)
57+
RecvDataHandler dfopRecvDataHandler = new RecvDataHandler(delegate (ResponseInfo respInfo, byte[] respData)
6358
{
64-
if (respInfo.isOk())
65-
{
66-
dfopResult = StringUtils.jsonDecode<DfopResult>(response);
67-
}
68-
6959
dfopResult.ResponseInfo = respInfo;
70-
dfopResult.Response = response;
60+
dfopResult.ResponseData = respData;
7161
});
7262

73-
mHttpManager.postMultipartDataRaw(dfopUrl, dfopHeaders, dfopData, null, dfopCompletionHandler);
63+
mHttpManager.postMultipartDataRaw(dfopUrl, dfopHeaders, dfopData, null, dfopRecvDataHandler);
7464

7565
return dfopResult;
7666
}

Qiniu/Processing/DfopResult.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66

77
namespace Qiniu.Processing
88
{
9-
public class DfopResult:HttpResult
9+
public class DfopResult
1010
{
11-
public DfopResult() { }
11+
public ResponseInfo ResponseInfo { get; set; }
12+
13+
public byte[] ResponseData { get; set; }
14+
15+
public string Response()
16+
{
17+
return Encoding.UTF8.GetString(ResponseData);
18+
}
1219
}
1320
}

0 commit comments

Comments
 (0)