@react-native-ohos/react-native-fileupload 1.1.1-rc.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/NativeRNFileupload.ts +7 -7
- package/{harmony/fileUpload/OAT.xml → OAT.xml} +46 -37
- package/{harmony/fileUpload/README.OpenSource → README.OpenSource} +10 -10
- package/README.md +2 -2
- package/harmony/fileUpload/LICENSE +19 -19
- package/harmony/fileUpload/build-profile.json5 +8 -28
- package/harmony/fileUpload/hvigorfile.ts +6 -6
- package/harmony/fileUpload/index.ets +3 -1
- package/harmony/fileUpload/obfuscation-rules.txt +17 -17
- package/harmony/fileUpload/oh-package.json5 +11 -11
- package/harmony/fileUpload/src/main/cpp/CMakeLists.txt +8 -8
- package/harmony/fileUpload/src/main/cpp/FileUploadPackage.h +36 -0
- package/harmony/fileUpload/src/main/ets/FileUpLoadModule.ts +106 -106
- package/harmony/fileUpload/src/main/ets/{FileUpLoadPackage.ts → FileUpLoadPackage.ets} +46 -46
- package/harmony/fileUpload/src/main/ets/Logger.ts +63 -63
- package/harmony/fileUpload/src/main/module.json5 +11 -11
- package/harmony/fileUpload/src/main/resources/base/element/string.json +8 -8
- package/harmony/fileUpload/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/fileUpload/src/main/resources/zh_CN/element/string.json +8 -8
- package/harmony/fileUpload/src/test/List.test.ets +4 -4
- package/harmony/fileUpload/src/test/LocalUnit.test.ets +32 -32
- package/harmony/fileUpload/{ts.ts → ts.ets} +1 -1
- package/harmony/fileupload.har +0 -0
- package/index.js +1 -1
- package/package.json +46 -43
- package/harmony/fileUpload/README.md +0 -165
- package/harmony/fileUpload/src/main/cpp/FileuploadPackage.h +0 -19
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/ComponentDescriptors.h +0 -22
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/EventEmitters.cpp +0 -18
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/EventEmitters.h +0 -19
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/Props.cpp +0 -21
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/Props.h +0 -20
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/ShadowNodes.cpp +0 -19
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/ShadowNodes.h +0 -25
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/States.cpp +0 -18
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/States.h +0 -23
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import {
|
|
26
|
-
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
27
|
-
import { FileUpLoadModule } from './FileUpLoadModule';
|
|
28
|
-
import { TM } from "./generated/ts";
|
|
29
|
-
|
|
30
|
-
class FileUpLoadModulesFactory extends TurboModulesFactory {
|
|
31
|
-
createTurboModule(name: string): TurboModule | null {
|
|
32
|
-
if (name === TM.RNFileupload.NAME) {
|
|
33
|
-
return new FileUpLoadModule(this.ctx)
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
hasTurboModule(name: string): boolean {
|
|
39
|
-
return name === TM.RNFileupload.NAME;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export class
|
|
44
|
-
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
|
45
|
-
return new FileUpLoadModulesFactory(ctx);
|
|
46
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { RNOHPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony';
|
|
26
|
+
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
27
|
+
import { FileUpLoadModule } from './FileUpLoadModule';
|
|
28
|
+
import { TM } from "./generated/ts";
|
|
29
|
+
|
|
30
|
+
class FileUpLoadModulesFactory extends TurboModulesFactory {
|
|
31
|
+
createTurboModule(name: string): TurboModule | null {
|
|
32
|
+
if (name === TM.RNFileupload.NAME) {
|
|
33
|
+
return new FileUpLoadModule(this.ctx)
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
hasTurboModule(name: string): boolean {
|
|
39
|
+
return name === TM.RNFileupload.NAME;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class FileUploadPackage extends RNOHPackage {
|
|
44
|
+
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
|
45
|
+
return new FileUpLoadModulesFactory(ctx);
|
|
46
|
+
}
|
|
47
47
|
}
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import hilog from '@ohos.hilog';
|
|
26
|
-
|
|
27
|
-
class Logger {
|
|
28
|
-
private domain : number;
|
|
29
|
-
private prefix : string;
|
|
30
|
-
private format : string = '%{public}s, %{public}s';
|
|
31
|
-
private isDebug : boolean;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* constructor.
|
|
35
|
-
*
|
|
36
|
-
* @param Prefix Identifies the log tag.
|
|
37
|
-
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
|
|
38
|
-
*/
|
|
39
|
-
constructor(prefix: string = 'MyApp', domain: number = 0xFF00, isDebug = false) {
|
|
40
|
-
this.prefix = prefix;
|
|
41
|
-
this.domain = domain;
|
|
42
|
-
this.isDebug = isDebug;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
debug(...args: string[]): void {
|
|
46
|
-
if (this.isDebug) {
|
|
47
|
-
hilog.debug(this.domain, this.prefix, this.format, args);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
info(...args: string[]): void {
|
|
52
|
-
hilog.info(this.domain, this.prefix, this.format, args);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
warn(...args: string[]) : void {
|
|
56
|
-
hilog.warn(this.domain, this.prefix, this.format, args);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
error(...args: string[]) : void {
|
|
60
|
-
hilog.error(this.domain, this.prefix, this.format, args);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import hilog from '@ohos.hilog';
|
|
26
|
+
|
|
27
|
+
class Logger {
|
|
28
|
+
private domain : number;
|
|
29
|
+
private prefix : string;
|
|
30
|
+
private format : string = '%{public}s, %{public}s';
|
|
31
|
+
private isDebug : boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* constructor.
|
|
35
|
+
*
|
|
36
|
+
* @param Prefix Identifies the log tag.
|
|
37
|
+
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
|
|
38
|
+
*/
|
|
39
|
+
constructor(prefix: string = 'MyApp', domain: number = 0xFF00, isDebug = false) {
|
|
40
|
+
this.prefix = prefix;
|
|
41
|
+
this.domain = domain;
|
|
42
|
+
this.isDebug = isDebug;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
debug(...args: string[]): void {
|
|
46
|
+
if (this.isDebug) {
|
|
47
|
+
hilog.debug(this.domain, this.prefix, this.format, args);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
info(...args: string[]): void {
|
|
52
|
+
hilog.info(this.domain, this.prefix, this.format, args);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
warn(...args: string[]) : void {
|
|
56
|
+
hilog.warn(this.domain, this.prefix, this.format, args);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
error(...args: string[]) : void {
|
|
60
|
+
hilog.error(this.domain, this.prefix, this.format, args);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
64
|
export default new Logger('RNFileupload', 0xFF00, false)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"module": {
|
|
3
|
-
"name": "fileupload",
|
|
4
|
-
"type": "har",
|
|
5
|
-
"deviceTypes": [
|
|
6
|
-
"default",
|
|
7
|
-
"tablet",
|
|
8
|
-
"2in1"
|
|
9
|
-
]
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"module": {
|
|
3
|
+
"name": "fileupload",
|
|
4
|
+
"type": "har",
|
|
5
|
+
"deviceTypes": [
|
|
6
|
+
"default",
|
|
7
|
+
"tablet",
|
|
8
|
+
"2in1"
|
|
9
|
+
]
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"string": [
|
|
3
|
-
{
|
|
4
|
-
"name": "page_show",
|
|
5
|
-
"value": "page from package"
|
|
6
|
-
}
|
|
7
|
-
]
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"string": [
|
|
3
|
+
{
|
|
4
|
+
"name": "page_show",
|
|
5
|
+
"value": "page from package"
|
|
6
|
+
}
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"string": [
|
|
3
|
-
{
|
|
4
|
-
"name": "page_show",
|
|
5
|
-
"value": "page from package"
|
|
6
|
-
}
|
|
7
|
-
]
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"string": [
|
|
3
|
+
{
|
|
4
|
+
"name": "page_show",
|
|
5
|
+
"value": "page from package"
|
|
6
|
+
}
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"string": [
|
|
3
|
-
{
|
|
4
|
-
"name": "page_show",
|
|
5
|
-
"value": "page from package"
|
|
6
|
-
}
|
|
7
|
-
]
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"string": [
|
|
3
|
+
{
|
|
4
|
+
"name": "page_show",
|
|
5
|
+
"value": "page from package"
|
|
6
|
+
}
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import localUnitTest from './LocalUnit.test';
|
|
2
|
-
|
|
3
|
-
export default function testsuite() {
|
|
4
|
-
localUnitTest();
|
|
1
|
+
import localUnitTest from './LocalUnit.test';
|
|
2
|
+
|
|
3
|
+
export default function testsuite() {
|
|
4
|
+
localUnitTest();
|
|
5
5
|
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
|
|
2
|
-
|
|
3
|
-
export default function localUnitTest() {
|
|
4
|
-
describe('localUnitTest',() => {
|
|
5
|
-
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
|
|
6
|
-
beforeAll(() => {
|
|
7
|
-
// Presets an action, which is performed only once before all test cases of the test suite start.
|
|
8
|
-
// This API supports only one parameter: preset action function.
|
|
9
|
-
});
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
// Presets an action, which is performed before each unit test case starts.
|
|
12
|
-
// The number of execution times is the same as the number of test cases defined by **it**.
|
|
13
|
-
// This API supports only one parameter: preset action function.
|
|
14
|
-
});
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
// Presets a clear action, which is performed after each unit test case ends.
|
|
17
|
-
// The number of execution times is the same as the number of test cases defined by **it**.
|
|
18
|
-
// This API supports only one parameter: clear action function.
|
|
19
|
-
});
|
|
20
|
-
afterAll(() => {
|
|
21
|
-
// Presets a clear action, which is performed after all test cases of the test suite end.
|
|
22
|
-
// This API supports only one parameter: clear action function.
|
|
23
|
-
});
|
|
24
|
-
it('assertContain', 0, () => {
|
|
25
|
-
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
|
|
26
|
-
let a = 'abc';
|
|
27
|
-
let b = 'b';
|
|
28
|
-
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
|
|
29
|
-
expect(a).assertContain(b);
|
|
30
|
-
expect(a).assertEqual(a);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
1
|
+
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
|
|
2
|
+
|
|
3
|
+
export default function localUnitTest() {
|
|
4
|
+
describe('localUnitTest',() => {
|
|
5
|
+
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
// Presets an action, which is performed only once before all test cases of the test suite start.
|
|
8
|
+
// This API supports only one parameter: preset action function.
|
|
9
|
+
});
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
// Presets an action, which is performed before each unit test case starts.
|
|
12
|
+
// The number of execution times is the same as the number of test cases defined by **it**.
|
|
13
|
+
// This API supports only one parameter: preset action function.
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
// Presets a clear action, which is performed after each unit test case ends.
|
|
17
|
+
// The number of execution times is the same as the number of test cases defined by **it**.
|
|
18
|
+
// This API supports only one parameter: clear action function.
|
|
19
|
+
});
|
|
20
|
+
afterAll(() => {
|
|
21
|
+
// Presets a clear action, which is performed after all test cases of the test suite end.
|
|
22
|
+
// This API supports only one parameter: clear action function.
|
|
23
|
+
});
|
|
24
|
+
it('assertContain', 0, () => {
|
|
25
|
+
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
|
|
26
|
+
let a = 'abc';
|
|
27
|
+
let b = 'b';
|
|
28
|
+
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
|
|
29
|
+
expect(a).assertContain(b);
|
|
30
|
+
expect(a).assertEqual(a);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
33
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./src/main/ets/FileUpLoadPackage";
|
|
1
|
+
export * from "./src/main/ets/FileUpLoadPackage";
|
|
2
2
|
export * from "./src/main/ets/FileUpLoadModule";
|
package/harmony/fileupload.har
CHANGED
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import NativeModule from "./NativeRNFileupload";
|
|
1
|
+
import NativeModule from "./NativeRNFileupload";
|
|
2
2
|
export default NativeModule;
|
package/package.json
CHANGED
|
@@ -1,44 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@react-native-ohos/react-native-fileupload",
|
|
3
|
-
"version": "1.1.1
|
|
4
|
-
"description": "A file upload plugin for react-native",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-fileupload --cpp-output-path ./harmony/fileUpload/src/main/cpp/generated --ets-output-path ./harmony/fileUpload/src/main/ets/generated --turbo-modules-spec-paths ./
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://
|
|
13
|
-
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-fileupload",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "A file upload plugin for react-native",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-fileupload --cpp-output-path ./harmony/fileUpload/src/main/cpp/generated --ets-output-path ./harmony/fileUpload/src/main/ets/generated --turbo-modules-spec-paths ./NativeRNFileUpload.ts"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-fileupload.git"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"registry": "https://registry.npmjs.org/",
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-component",
|
|
20
|
+
"react-native",
|
|
21
|
+
"file",
|
|
22
|
+
"upload"
|
|
23
|
+
],
|
|
24
|
+
"harmony": {
|
|
25
|
+
"alias": "react-native-fileupload",
|
|
26
|
+
"autolinking": {
|
|
27
|
+
"etsPackageClassName":"FileUploadPackage",
|
|
28
|
+
"cppPackageClassName":"FileUploadPackage",
|
|
29
|
+
"cmakeLibraryTargetName": "rnoh_fileupload",
|
|
30
|
+
"ohPackageName": "@react-native-ohos/react-native-fileupload"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"overrides": {
|
|
34
|
+
"@react-native/codegen": "0.74.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"react-native-fileupload": "1.1.0",
|
|
38
|
+
"react": "18.2.0",
|
|
39
|
+
"react-native": "0.72.5"
|
|
40
|
+
},
|
|
41
|
+
"author": "Philipp Krone",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-fileupload/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-fileupload"
|
|
44
47
|
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# react-native-fileupload [](https://www.npmjs.com/package/react-native-fileupload)
|
|
2
|
-
|
|
3
|
-
**Important**: iOS version created by booxood (react-native-file-upload). This repository is the continuation of https://github.com/booxood/react-native-file-upload.
|
|
4
|
-
|
|
5
|
-
* Support to upload multiple files at a time
|
|
6
|
-
* Support to files and fields
|
|
7
|
-
|
|
8
|
-
## Getting started
|
|
9
|
-
|
|
10
|
-
`npm install react-native-fileupload --save`
|
|
11
|
-
|
|
12
|
-
### iOS
|
|
13
|
-
1. In XCode, in the project navigator, right click `your project` ➜ `Add Files to [your project's name]`
|
|
14
|
-
2. Go to `node_modules` ➜ `react-native-fileupload` and add `FileUpload.m`
|
|
15
|
-
3. Run your project (`Cmd+R`)
|
|
16
|
-
|
|
17
|
-
### Android
|
|
18
|
-
|
|
19
|
-
*Note: Android support requires React Native 0.12 or later*
|
|
20
|
-
|
|
21
|
-
* Edit `android/settings.gradle` to look like this:
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
rootProject.name = 'MyApp'
|
|
25
|
-
|
|
26
|
-
include ':app'
|
|
27
|
-
|
|
28
|
-
//Add the following two lines:
|
|
29
|
-
include ':react-native-fileupload'
|
|
30
|
-
project(':react-native-fileupload').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fileupload/android')
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
* Edit `android/app/build.gradle` (note: **app** folder) to look like this:
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
apply plugin: 'com.android.application'
|
|
37
|
-
|
|
38
|
-
android {
|
|
39
|
-
...
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
dependencies {
|
|
43
|
-
compile fileTree(dir: 'libs', include: ['*.jar'])
|
|
44
|
-
compile 'com.android.support:appcompat-v7:23.0.0'
|
|
45
|
-
compile 'com.facebook.react:react-native:0.12.+'
|
|
46
|
-
|
|
47
|
-
// Add this line:
|
|
48
|
-
compile project(':react-native-fileupload')
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
* Edit your `MainActivity.java` (deep in `android/app/src/main/java/...`) to look like this:
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
package com.myapp;
|
|
56
|
-
|
|
57
|
-
// Add this line:
|
|
58
|
-
import com.yoloci.fileupload.FileUploadPackage;
|
|
59
|
-
|
|
60
|
-
import android.app.Activity;
|
|
61
|
-
....
|
|
62
|
-
|
|
63
|
-
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
|
|
64
|
-
|
|
65
|
-
private ReactInstanceManager mReactInstanceManager;
|
|
66
|
-
private ReactRootView mReactRootView;
|
|
67
|
-
|
|
68
|
-
@Override
|
|
69
|
-
protected void onCreate(Bundle savedInstanceState) {
|
|
70
|
-
super.onCreate(savedInstanceState);
|
|
71
|
-
mReactRootView = new ReactRootView(this);
|
|
72
|
-
|
|
73
|
-
mReactInstanceManager = ReactInstanceManager.builder()
|
|
74
|
-
.setApplication(getApplication())
|
|
75
|
-
.setBundleAssetName("index.android.bundle")
|
|
76
|
-
.setJSMainModuleName("index.android")
|
|
77
|
-
.addPackage(new MainReactPackage())
|
|
78
|
-
|
|
79
|
-
// and this line:
|
|
80
|
-
.addPackage(new FileUploadPackage())
|
|
81
|
-
|
|
82
|
-
.setUseDeveloperSupport(BuildConfig.DEBUG)
|
|
83
|
-
.setInitialLifecycleState(LifecycleState.RESUMED)
|
|
84
|
-
.build();
|
|
85
|
-
|
|
86
|
-
mReactRootView.startReactApplication(mReactInstanceManager, "MyApp", null);
|
|
87
|
-
|
|
88
|
-
setContentView(mReactRootView);
|
|
89
|
-
}
|
|
90
|
-
...
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Usage
|
|
95
|
-
|
|
96
|
-
All you need is to export module `var FileUpload = require('NativeModules').FileUpload;` and direct invoke `FileUpload.upload`.
|
|
97
|
-
|
|
98
|
-
```javascript
|
|
99
|
-
'use strict';
|
|
100
|
-
|
|
101
|
-
var React = require('react-native');
|
|
102
|
-
var FileUpload = require('NativeModules').FileUpload;
|
|
103
|
-
|
|
104
|
-
var {
|
|
105
|
-
AppRegistry,
|
|
106
|
-
StyleSheet,
|
|
107
|
-
Text,
|
|
108
|
-
View,
|
|
109
|
-
} = React;
|
|
110
|
-
|
|
111
|
-
var FileUploadDemo = React.createClass({
|
|
112
|
-
componentDidMount: function() {
|
|
113
|
-
var obj = {
|
|
114
|
-
uploadUrl: 'http://127.0.0.1:3000',
|
|
115
|
-
method: 'POST', // default 'POST',support 'POST' and 'PUT'
|
|
116
|
-
headers: {
|
|
117
|
-
'Accept': 'application/json',
|
|
118
|
-
},
|
|
119
|
-
fields: {
|
|
120
|
-
'hello': 'world',
|
|
121
|
-
},
|
|
122
|
-
files: [
|
|
123
|
-
{
|
|
124
|
-
name: 'one', // optional, if none then `filename` is used instead
|
|
125
|
-
filename: 'one.w4a', // require, file name
|
|
126
|
-
filepath: '/xxx/one.w4a', // require, file absoluete path
|
|
127
|
-
filetype: 'audio/x-m4a', // options, if none, will get mimetype from `filepath` extension
|
|
128
|
-
},
|
|
129
|
-
]
|
|
130
|
-
};
|
|
131
|
-
FileUpload.upload(obj, function(err, result) {
|
|
132
|
-
console.log('upload:', err, result);
|
|
133
|
-
})
|
|
134
|
-
},
|
|
135
|
-
render: function() {
|
|
136
|
-
return (
|
|
137
|
-
<View style={styles.container}>
|
|
138
|
-
<Text style={styles.welcome}>
|
|
139
|
-
Welcome to React Native!
|
|
140
|
-
</Text>
|
|
141
|
-
</View>
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
var styles = StyleSheet.create({
|
|
147
|
-
container: {
|
|
148
|
-
flex: 1,
|
|
149
|
-
justifyContent: 'center',
|
|
150
|
-
alignItems: 'center',
|
|
151
|
-
backgroundColor: '#F5FCFF',
|
|
152
|
-
},
|
|
153
|
-
welcome: {
|
|
154
|
-
fontSize: 20,
|
|
155
|
-
textAlign: 'center',
|
|
156
|
-
margin: 10,
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
AppRegistry.registerComponent('FileUploadDemo', () => FileUploadDemo);
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## License
|
|
164
|
-
|
|
165
|
-
MIT
|