File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . IO ;
2
3
using System . Net ;
3
4
using System . Net . Http ;
5
+ using System . Text ;
4
6
using System . Threading . Tasks ;
5
7
using Cuiliang . AliyunOssSdk . Api . Common . Consts ;
6
8
using Cuiliang . AliyunOssSdk . Entites ;
@@ -116,9 +118,14 @@ private async Task<OssResult<TResult>> ProcessResponseInternal(HttpResponseMessa
116
118
//错误的http代码
117
119
if ( response . Content ? . Headers . ContentLength > 0 )
118
120
{
121
+ //var responseContent = await response.Content.ReadAsStreamAsync();
122
+ //var errorResult =
123
+ // SerializeHelper.Deserialize<ErrorResult>(responseContent);
124
+
125
+ var responseContent = await response . Content . ReadAsStringAsync ( ) ;
119
126
var errorResult =
120
- SerializeHelper . Deserialize < ErrorResult > ( await response . Content . ReadAsStreamAsync ( ) ) ;
121
-
127
+ SerializeHelper . Deserialize < ErrorResult > ( responseContent ) ;
128
+
122
129
return new OssResult < TResult > ( )
123
130
{
124
131
IsSuccess = false ,
Original file line number Diff line number Diff line change @@ -28,6 +28,24 @@ public static T Deserialize<T>(Stream xmlStream)
28
28
29
29
}
30
30
31
+ /// <summary>
32
+ /// XML 文本 -》 对象
33
+ /// </summary>
34
+ /// <typeparam name="T"></typeparam>
35
+ /// <param name="stringContent"></param>
36
+ /// <returns></returns>
37
+ public static T Deserialize < T > ( string stringContent )
38
+ {
39
+ var serializer = new XmlSerializer ( typeof ( T ) ) ;
40
+
41
+ using ( TextReader reader = new StringReader ( stringContent ) )
42
+ {
43
+ return ( T ) serializer . Deserialize ( reader ) ;
44
+ }
45
+
46
+
47
+ }
48
+
31
49
/// <summary>
32
50
/// 将一个对象序列化为XML字符串
33
51
/// </summary>
You can’t perform that action at this time.
0 commit comments