Skip to content

Commit 41e6159

Browse files
author
feng
committed
fix:文件上传返回
1 parent d158f65 commit 41e6159

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

harmony/blobUtil.har

96 Bytes
Binary file not shown.

harmony/blobUtil/BuildProfile.ets

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
/**
2+
* Use these variables when you tailor your ArkTS code. They must be of the const type.
3+
*/
4+
export const HAR_VERSION = '0.19.6-0.0.6';
5+
export const BUILD_MODE_NAME = 'debug';
6+
export const DEBUG = true;
7+
export const TARGET_NAME = 'default';
8+
9+
/**
10+
* BuildProfile Class is used only for compatibility purposes.
11+
*/
112
export default class BuildProfile {
2-
static readonly HAR_VERSION = '1.0.0';
3-
static readonly BUILD_MODE_NAME = 'debug';
4-
static readonly DEBUG = true;
13+
static readonly HAR_VERSION = HAR_VERSION;
14+
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
15+
static readonly DEBUG = DEBUG;
16+
static readonly TARGET_NAME = TARGET_NAME;
517
}

harmony/blobUtil/oh-package-lock.json5

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

harmony/blobUtil/oh-package.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-native-oh-tpl/react-native-blob-util",
3-
"version": "0.19.6-0.0.2",
3+
"version": "0.19.6-0.0.6",
44
"description": "Please describe the basic information.",
55
"main": "Index.ets",
66
"author": "",

harmony/blobUtil/src/main/ets/ReactNativeBlobUtil/ReactNativeBlobUtilReq.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import util from '@ohos.util';
55
import wifiManage from '@ohos.wifiManager';
66
import { BusinessError } from '@ohos.base';
77
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';
99
import ConfigType, { ResponseInfo, RespType } from './ReactNativeBlobUtilConfig';
1010

1111
const FILE_PREFIX = 'ReactNativeBlobUtil-file://';
@@ -50,7 +50,7 @@ class DataSendProgressInfo {
5050
}
5151

5252
export default class ReactNativeBlobUtilReq {
53-
private ctx: TurboModuleContext | undefined = undefined
53+
private ctx: RNOHContext | undefined = undefined
5454
private context: common.UIAbilityContext | undefined = undefined
5555

5656
destPath: string;
@@ -59,6 +59,7 @@ export default class ReactNativeBlobUtilReq {
5959
responseFormat: ResponseFormat = ResponseFormat.Auto;
6060
resHeaders: Object;
6161
totalReceiveData: Array<ArrayBuffer> = [];
62+
allData: Array<any> = [];
6263

6364
downloadTimer: number = 0;
6465
uploadTimer: number = 0;
@@ -72,7 +73,7 @@ export default class ReactNativeBlobUtilReq {
7273
}
7374
taskId: string;
7475

75-
constructor(ctx: TurboModuleContext, context: common.UIAbilityContext) {
76+
constructor(ctx: RNOHContext, context: common.UIAbilityContext) {
7677
this.ctx = ctx;
7778
this.context = context;
7879
this.httpRequest = http.createHttp();
@@ -154,6 +155,10 @@ export default class ReactNativeBlobUtilReq {
154155
}
155156

156157
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)
157162
this.totalReceiveData.push(data);
158163
})
159164

@@ -217,7 +222,7 @@ export default class ReactNativeBlobUtilReq {
217222
callback(null, RNFB_RESPONSE.BASE64, resData, resInfo);
218223
return;
219224
}
220-
callback(null, RNFB_RESPONSE.UTF8, result.toString(), resInfo);
225+
callback(null, RNFB_RESPONSE.UTF8, JSON.stringify(this.allData), resInfo);
221226
}
222227
break;
223228
case ResponseType.FileStorage:

0 commit comments

Comments
 (0)