@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
package/LICENSE
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Liucw & PhilippKrone
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
-
the Software without restriction, including without limitation the rights to
|
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
-
subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Liucw & PhilippKrone
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/NativeRNFileupload.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
|
|
2
|
-
import { TurboModuleRegistry } from "react-native";
|
|
3
|
-
|
|
4
|
-
export interface Spec extends TurboModule {
|
|
5
|
-
upload(options: Object, callback: (err: string, result: string)=>void): void;
|
|
6
|
-
}
|
|
7
|
-
|
|
1
|
+
import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
|
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
upload(options: Object, callback: (err: string, result: string)=>void): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
8
|
export default TurboModuleRegistry.getEnforcing<Spec>("RNFileupload");
|
|
@@ -1,38 +1,47 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<configuration>
|
|
3
|
-
<oatconfig>
|
|
4
|
-
<licensefile>LICENSE</licensefile>
|
|
5
|
-
<filefilterlist>
|
|
6
|
-
<filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
7
|
-
<filteritem type="
|
|
8
|
-
<filteritem type="
|
|
9
|
-
|
|
10
|
-
<filteritem type="filename" name="
|
|
11
|
-
<filteritem type="
|
|
12
|
-
<filteritem type="
|
|
13
|
-
<filteritem type="
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<filteritem type="
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<filteritem type="
|
|
22
|
-
<filteritem type="filepath" name="
|
|
23
|
-
|
|
24
|
-
<filteritem type="
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<filteritem type="filename" name="
|
|
28
|
-
<filteritem type="filename" name="
|
|
29
|
-
<filteritem type="filename" name="
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<configuration>
|
|
3
|
+
<oatconfig>
|
|
4
|
+
<licensefile>LICENSE</licensefile>
|
|
5
|
+
<filefilterlist>
|
|
6
|
+
<filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
7
|
+
<filteritem type="filepath" name="harmony/fileUpload/src/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
|
|
8
|
+
<filteritem type="filepath" name="harmony/fileUpload/index.ets" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
|
|
9
|
+
<filteritem type="filepath" name="harmony/fileUpload/ts.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
|
|
10
|
+
<filteritem type="filename" name="NativeRNFileupload.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
|
|
11
|
+
<filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加版权头"/>
|
|
12
|
+
<filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加版权头"/>
|
|
13
|
+
<filteritem type="filename" name="*.proto" desc="资源文件,不需要添加版权头"/>
|
|
14
|
+
<filteritem type="filename" name="*.json" desc="资源文件,不需要添加版权头"/>
|
|
15
|
+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
16
|
+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
17
|
+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
18
|
+
<filteritem type="filename" name="LICENSE" desc="原三方库证书文件无需更改,因此添加过滤"/>
|
|
19
|
+
</filefilter>
|
|
20
|
+
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
21
|
+
<filteritem type="filepath" name="harmony/fileUpload/src/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
|
|
22
|
+
<filteritem type="filepath" name="harmony/fileUpload/index.ets" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
|
|
23
|
+
<filteritem type="filepath" name="harmony/fileUpload/ts.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
|
|
24
|
+
<filteritem type="filename" name="NativeRNFileupload.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
|
|
25
|
+
<filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加许可证头"/>
|
|
26
|
+
<filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加许可证头"/>
|
|
27
|
+
<filteritem type="filename" name="LICENSE" desc="原三方库证书文件无需更改,因此添加过滤"/>
|
|
28
|
+
<filteritem type="filename" name="*.proto" desc="资源文件,不需要添加许可证头"/>
|
|
29
|
+
<filteritem type="filename" name="*.json" desc="资源文件,不需要添加许可证头"/>
|
|
30
|
+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
31
|
+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
32
|
+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
33
|
+
</filefilter>
|
|
34
|
+
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for resources files policies">
|
|
35
|
+
<filteritem type="filepath" name="harmony/fileupload.har" desc="项目打包文件"/>
|
|
36
|
+
<filteritem type="filename" name="icon.png" desc="应用图标"/>
|
|
37
|
+
<filteritem type="filename" name="app_icon.png" desc="应用图标"/>
|
|
38
|
+
<filteritem type="filename" name="warn.png" desc="页面展示图标"/>
|
|
39
|
+
</filefilter>
|
|
40
|
+
</filefilterlist>
|
|
41
|
+
<policylist>
|
|
42
|
+
<policy name="projectPolicy" desc="">
|
|
43
|
+
<policyitem type="license" name="MIT" path=".*" desc="license under the MIT"/>
|
|
44
|
+
</policy>
|
|
45
|
+
</policylist>
|
|
46
|
+
</oatconfig>
|
|
38
47
|
</configuration>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"Name": "react-native-fileupload",
|
|
4
|
-
"License": "MIT License",
|
|
5
|
-
"License File": "
|
|
6
|
-
"Version Number": "1.1.0",
|
|
7
|
-
"Owner" : "
|
|
8
|
-
"Upstream URL": "https://github.com/PhilippKrone/react-native-fileupload",
|
|
9
|
-
"Description": "A file upload plugin for react-native."
|
|
10
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "react-native-fileupload",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File": "LICENSE",
|
|
6
|
+
"Version Number": "1.1.0",
|
|
7
|
+
"Owner" : "xiafeng@huawei.com",
|
|
8
|
+
"Upstream URL": "https://github.com/PhilippKrone/react-native-fileupload",
|
|
9
|
+
"Description": "A file upload plugin for react-native."
|
|
10
|
+
}
|
|
11
11
|
]
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# @react-native-
|
|
2
|
-
This project is based on [react-native-fileupload](https://github.com/PhilippKrone/react-native-fileupload)
|
|
1
|
+
# @react-native-ohos/react-native-fileupload
|
|
2
|
+
This project is based on [react-native-fileupload](https://github.com/PhilippKrone/react-native-fileupload)@1.1.0
|
|
3
3
|
## Documentation
|
|
4
4
|
[中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-fileupload.md)
|
|
5
5
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Liucw & PhilippKrone
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
-
the Software without restriction, including without limitation the rights to
|
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
-
subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Liucw & PhilippKrone
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
20
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"apiType": "stageMode",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"obfuscation": {
|
|
10
|
-
"ruleOptions": {
|
|
11
|
-
"enable": true,
|
|
12
|
-
"files": [
|
|
13
|
-
"./obfuscation-rules.txt"
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
"consumerFiles": [
|
|
17
|
-
"./consumer-rules.txt"
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
"targets": [
|
|
24
|
-
{
|
|
25
|
-
"name": "default"
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"apiType": "stageMode",
|
|
3
|
+
"targets": [
|
|
4
|
+
{
|
|
5
|
+
"name": "default"
|
|
6
|
+
}
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { harTasks } from '@ohos/hvigor-ohos-plugin';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
5
|
-
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
|
|
6
|
-
}
|
|
1
|
+
import { harTasks } from '@ohos/hvigor-ohos-plugin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
5
|
+
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
|
|
6
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# Define project specific obfuscation rules here.
|
|
2
|
-
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
-
#
|
|
4
|
-
# For more details, see
|
|
5
|
-
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
|
|
6
|
-
|
|
7
|
-
# Obfuscation options:
|
|
8
|
-
# -disable-obfuscation: disable all obfuscations
|
|
9
|
-
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
-
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
-
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
-
# -remove-log: remove all console.* statements
|
|
13
|
-
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
-
# -apply-namecache: reuse the given cache file
|
|
15
|
-
|
|
16
|
-
# Keep options:
|
|
17
|
-
# -keep-property-name: specifies property names that you want to keep
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
18
|
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
@@ -1,11 +1,11 @@
|
|
|
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.ets",
|
|
6
|
-
"author": "",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"@rnoh/react-native-openharmony": "file:../react_native_openharmony"
|
|
10
|
-
}
|
|
11
|
-
}
|
|
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.ets",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@rnoh/react-native-openharmony": "file:../react_native_openharmony"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.13)
|
|
2
|
-
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
|
-
|
|
4
|
-
set(rnoh_fileupload_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
|
|
5
|
-
file(GLOB_RECURSE rnoh_fileupload_generated_SRC "${rnoh_fileupload_generated_dir}/**/*.cpp")
|
|
6
|
-
file(GLOB rnoh_fileupload_SRC CONFIGURE_DEPENDS *.cpp)
|
|
7
|
-
add_library(rnoh_fileupload SHARED ${rnoh_fileupload_SRC} ${rnoh_fileupload_generated_SRC})
|
|
8
|
-
target_include_directories(rnoh_fileupload PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_fileupload_generated_dir}
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
|
+
|
|
4
|
+
set(rnoh_fileupload_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
|
|
5
|
+
file(GLOB_RECURSE rnoh_fileupload_generated_SRC "${rnoh_fileupload_generated_dir}/**/*.cpp")
|
|
6
|
+
file(GLOB rnoh_fileupload_SRC CONFIGURE_DEPENDS *.cpp)
|
|
7
|
+
add_library(rnoh_fileupload SHARED ${rnoh_fileupload_SRC} ${rnoh_fileupload_generated_SRC})
|
|
8
|
+
target_include_directories(rnoh_fileupload PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_fileupload_generated_dir})
|
|
9
9
|
target_link_libraries(rnoh_fileupload PUBLIC rnoh)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2025 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
|
+
#ifndef FILEUPLOADPACKAGE_H
|
|
25
|
+
#define FILEUPLOADPACKAGE_H
|
|
26
|
+
|
|
27
|
+
#include "generated/RNOH/generated/BaseReactNativeFileuploadPackage.h"
|
|
28
|
+
#pragma once
|
|
29
|
+
|
|
30
|
+
namespace rnoh {
|
|
31
|
+
class FileUploadPackage : public BaseReactNativeFileuploadPackage {
|
|
32
|
+
using Super = BaseReactNativeFileuploadPackage;
|
|
33
|
+
using Super::Super;
|
|
34
|
+
};
|
|
35
|
+
} // namespace rnoh
|
|
36
|
+
#endif // FILEUPLOADPACKAGE_H
|
|
@@ -1,107 +1,107 @@
|
|
|
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 { TurboModule, TurboModuleContext } from "@rnoh/react-native-openharmony/ts";
|
|
26
|
-
import Logger from './Logger';
|
|
27
|
-
import { TM } from './generated/ts';
|
|
28
|
-
import request from '@ohos.request';
|
|
29
|
-
import { BusinessError } from '@ohos.base';
|
|
30
|
-
import { JSON } from '@kit.ArkTS';
|
|
31
|
-
|
|
32
|
-
export class FileUpLoadModule extends TurboModule implements TM.RNFileupload.Spec{
|
|
33
|
-
constructor(protected ctx: TurboModuleContext) {
|
|
34
|
-
super(ctx);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
upload(options: Object, callback: (err: string, result: string)=>void): void {
|
|
38
|
-
|
|
39
|
-
let filesArray = new Array();
|
|
40
|
-
for (let index = 0; index < options['files'].length; index++) {
|
|
41
|
-
let Object = {
|
|
42
|
-
filename: '',
|
|
43
|
-
name: '',
|
|
44
|
-
uri: '',
|
|
45
|
-
type: ''
|
|
46
|
-
};
|
|
47
|
-
let filesItem = options['files'][index];
|
|
48
|
-
Object.filename = filesItem['filename'];
|
|
49
|
-
let path = filesItem['filepath'].substring(0, filesItem['filepath'].lastIndexOf('/'));
|
|
50
|
-
if (path == this.ctx.uiAbilityContext.cacheDir || path == 'file://' + this.ctx.uiAbilityContext.cacheDir) {
|
|
51
|
-
Object.uri = 'internal://cache/' + filesItem['filename'];
|
|
52
|
-
} else if (filesItem['filepath'] == 'internal://cache/' + filesItem['filename']) {
|
|
53
|
-
Object.uri = filesItem['filepath'];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let i = filesItem['filename'].lastIndexOf('.')
|
|
57
|
-
let type = filesItem['filename'].substring(i + 1);
|
|
58
|
-
Object.type = filesItem['filetype'] ? filesItem['filetype'] : type;
|
|
59
|
-
Object.name = filesItem['name'] ? filesItem['name'] : 'file';
|
|
60
|
-
filesArray.push(Object);
|
|
61
|
-
}
|
|
62
|
-
let uploadConfig: request.UploadConfig = {
|
|
63
|
-
url: options['uploadUrl'],
|
|
64
|
-
header: options['headers'],
|
|
65
|
-
method: options['method'],
|
|
66
|
-
files: filesArray,
|
|
67
|
-
data: [
|
|
68
|
-
options['fields']
|
|
69
|
-
],
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
let uploadTask: request.UploadTask;
|
|
73
|
-
let responseMessage: string
|
|
74
|
-
try {
|
|
75
|
-
request.uploadFile(this.ctx.uiAbilityContext, uploadConfig).then((data: request.UploadTask) => {
|
|
76
|
-
uploadTask = data;
|
|
77
|
-
uploadTask.on('complete', (taskStates: Array<request.TaskState>) => {
|
|
78
|
-
for (let i = 0; i < taskStates.length; i++) {
|
|
79
|
-
Logger.info(`FileUpLoad complete taskState: ${JSON.stringify(taskStates)}`);
|
|
80
|
-
if (taskStates[i].responseCode == 0) {
|
|
81
|
-
responseMessage = taskStates[i].message;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
callback('',responseMessage !== '' ? responseMessage : 'File uploaded successfully.');
|
|
85
|
-
removeEvent(uploadTask);
|
|
86
|
-
});
|
|
87
|
-
uploadTask.on('fail', (taskStates: Array<request.TaskState>) => {
|
|
88
|
-
for (let i = 0; i < taskStates.length; i++) {
|
|
89
|
-
Logger.info(`FileUpLoad fail taskState: ${JSON.stringify(taskStates[i])}`);
|
|
90
|
-
responseMessage = taskStates[i].message;
|
|
91
|
-
}
|
|
92
|
-
callback(responseMessage, '');
|
|
93
|
-
removeEvent(uploadTask);
|
|
94
|
-
});
|
|
95
|
-
}).catch((err: BusinessError) => {
|
|
96
|
-
Logger.error(`Failed to request the upload. Code: ${err.code}, message: ${err.message}`);
|
|
97
|
-
});
|
|
98
|
-
} catch (err) {
|
|
99
|
-
Logger.error(`FileUpLoad: Invoke uploadFile failed, code is ${err.code}, message is ${err.message}`);
|
|
100
|
-
callback(err.message,'');
|
|
101
|
-
}
|
|
102
|
-
const removeEvent = (uploadTask) => {
|
|
103
|
-
uploadTask.off('fail');
|
|
104
|
-
uploadTask.off('complete');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
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 { TurboModule, TurboModuleContext } from "@rnoh/react-native-openharmony/ts";
|
|
26
|
+
import Logger from './Logger';
|
|
27
|
+
import { TM } from './generated/ts';
|
|
28
|
+
import request from '@ohos.request';
|
|
29
|
+
import { BusinessError } from '@ohos.base';
|
|
30
|
+
import { JSON } from '@kit.ArkTS';
|
|
31
|
+
|
|
32
|
+
export class FileUpLoadModule extends TurboModule implements TM.RNFileupload.Spec{
|
|
33
|
+
constructor(protected ctx: TurboModuleContext) {
|
|
34
|
+
super(ctx);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
upload(options: Object, callback: (err: string, result: string)=>void): void {
|
|
38
|
+
|
|
39
|
+
let filesArray = new Array();
|
|
40
|
+
for (let index = 0; index < options['files'].length; index++) {
|
|
41
|
+
let Object = {
|
|
42
|
+
filename: '',
|
|
43
|
+
name: '',
|
|
44
|
+
uri: '',
|
|
45
|
+
type: ''
|
|
46
|
+
};
|
|
47
|
+
let filesItem = options['files'][index];
|
|
48
|
+
Object.filename = filesItem['filename'];
|
|
49
|
+
let path = filesItem['filepath'].substring(0, filesItem['filepath'].lastIndexOf('/'));
|
|
50
|
+
if (path == this.ctx.uiAbilityContext.cacheDir || path == 'file://' + this.ctx.uiAbilityContext.cacheDir) {
|
|
51
|
+
Object.uri = 'internal://cache/' + filesItem['filename'];
|
|
52
|
+
} else if (filesItem['filepath'] == 'internal://cache/' + filesItem['filename']) {
|
|
53
|
+
Object.uri = filesItem['filepath'];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let i = filesItem['filename'].lastIndexOf('.')
|
|
57
|
+
let type = filesItem['filename'].substring(i + 1);
|
|
58
|
+
Object.type = filesItem['filetype'] ? filesItem['filetype'] : type;
|
|
59
|
+
Object.name = filesItem['name'] ? filesItem['name'] : 'file';
|
|
60
|
+
filesArray.push(Object);
|
|
61
|
+
}
|
|
62
|
+
let uploadConfig: request.UploadConfig = {
|
|
63
|
+
url: options['uploadUrl'],
|
|
64
|
+
header: options['headers'],
|
|
65
|
+
method: options['method'],
|
|
66
|
+
files: filesArray,
|
|
67
|
+
data: [
|
|
68
|
+
options['fields']
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
let uploadTask: request.UploadTask;
|
|
73
|
+
let responseMessage: string
|
|
74
|
+
try {
|
|
75
|
+
request.uploadFile(this.ctx.uiAbilityContext, uploadConfig).then((data: request.UploadTask) => {
|
|
76
|
+
uploadTask = data;
|
|
77
|
+
uploadTask.on('complete', (taskStates: Array<request.TaskState>) => {
|
|
78
|
+
for (let i = 0; i < taskStates.length; i++) {
|
|
79
|
+
Logger.info(`FileUpLoad complete taskState: ${JSON.stringify(taskStates)}`);
|
|
80
|
+
if (taskStates[i].responseCode == 0) {
|
|
81
|
+
responseMessage = taskStates[i].message;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
callback('',responseMessage !== '' ? responseMessage : 'File uploaded successfully.');
|
|
85
|
+
removeEvent(uploadTask);
|
|
86
|
+
});
|
|
87
|
+
uploadTask.on('fail', (taskStates: Array<request.TaskState>) => {
|
|
88
|
+
for (let i = 0; i < taskStates.length; i++) {
|
|
89
|
+
Logger.info(`FileUpLoad fail taskState: ${JSON.stringify(taskStates[i])}`);
|
|
90
|
+
responseMessage = taskStates[i].message;
|
|
91
|
+
}
|
|
92
|
+
callback(responseMessage, '');
|
|
93
|
+
removeEvent(uploadTask);
|
|
94
|
+
});
|
|
95
|
+
}).catch((err: BusinessError) => {
|
|
96
|
+
Logger.error(`Failed to request the upload. Code: ${err.code}, message: ${err.message}`);
|
|
97
|
+
});
|
|
98
|
+
} catch (err) {
|
|
99
|
+
Logger.error(`FileUpLoad: Invoke uploadFile failed, code is ${err.code}, message is ${err.message}`);
|
|
100
|
+
callback(err.message,'');
|
|
101
|
+
}
|
|
102
|
+
const removeEvent = (uploadTask) => {
|
|
103
|
+
uploadTask.off('fail');
|
|
104
|
+
uploadTask.off('complete');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
107
|
}
|