@@ -5,7 +5,7 @@ import util from '@ohos.util';
5
5
import wifiManage from '@ohos.wifiManager' ;
6
6
import { BusinessError } from '@ohos.base' ;
7
7
import common from '@ohos.app.ability.common' ;
8
- import { TurboModuleContext } from '@rnoh/react-native-openharmony/ts' ;
8
+ import { RNOHContext } from '@rnoh/react-native-openharmony/ts' ;
9
9
import ConfigType , { ResponseInfo , RespType } from './ReactNativeBlobUtilConfig' ;
10
10
11
11
const FILE_PREFIX = 'ReactNativeBlobUtil-file://' ;
@@ -50,7 +50,7 @@ class DataSendProgressInfo {
50
50
}
51
51
52
52
export default class ReactNativeBlobUtilReq {
53
- private ctx : TurboModuleContext | undefined = undefined
53
+ private ctx : RNOHContext | undefined = undefined
54
54
private context : common . UIAbilityContext | undefined = undefined
55
55
56
56
destPath : string ;
@@ -59,6 +59,7 @@ export default class ReactNativeBlobUtilReq {
59
59
responseFormat : ResponseFormat = ResponseFormat . Auto ;
60
60
resHeaders : Object ;
61
61
totalReceiveData : Array < ArrayBuffer > = [ ] ;
62
+ allData : Array < any > = [ ] ;
62
63
63
64
downloadTimer : number = 0 ;
64
65
uploadTimer : number = 0 ;
@@ -72,7 +73,7 @@ export default class ReactNativeBlobUtilReq {
72
73
}
73
74
taskId : string ;
74
75
75
- constructor ( ctx : TurboModuleContext , context : common . UIAbilityContext ) {
76
+ constructor ( ctx : RNOHContext , context : common . UIAbilityContext ) {
76
77
this . ctx = ctx ;
77
78
this . context = context ;
78
79
this . httpRequest = http . createHttp ( ) ;
@@ -154,6 +155,10 @@ export default class ReactNativeBlobUtilReq {
154
155
}
155
156
156
157
this . httpRequest . on ( 'dataReceive' , ( data : ArrayBuffer ) => {
158
+ // 解码成字符串
159
+ var decodedString = String . fromCharCode . apply ( null , new Uint8Array ( data ) )
160
+ console . log ( `decodedString: ${ decodedString } ` )
161
+ this . allData . push ( decodedString )
157
162
this . totalReceiveData . push ( data ) ;
158
163
} )
159
164
@@ -217,7 +222,7 @@ export default class ReactNativeBlobUtilReq {
217
222
callback ( null , RNFB_RESPONSE . BASE64 , resData , resInfo ) ;
218
223
return ;
219
224
}
220
- callback ( null , RNFB_RESPONSE . UTF8 , result . toString ( ) , resInfo ) ;
225
+ callback ( null , RNFB_RESPONSE . UTF8 , JSON . stringify ( this . allData ) , resInfo ) ;
221
226
}
222
227
break ;
223
228
case ResponseType . FileStorage :
0 commit comments