@react-native-ohos/react-native-fileupload 1.2.0-rc.1 → 1.2.1-beta.2
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/CHANGELOG.md +7 -7
- package/COMMITTERS.md +6 -6
- package/LICENSE +20 -20
- package/NativeRNFileupload.ts +7 -7
- package/README.OpenSource +10 -10
- package/README.md +9 -9
- package/harmony/fileUpload/LICENSE +19 -19
- package/harmony/fileUpload/README.OpenSource +10 -10
- package/harmony/fileUpload/README.md +164 -164
- package/harmony/fileUpload/build-profile.json5 +28 -28
- package/harmony/fileUpload/hvigorfile.ts +6 -6
- package/harmony/fileUpload/index.ets +1 -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 +18 -18
- package/harmony/fileUpload/src/main/cpp/generated/RNOH/generated/BaseReactNativeFileuploadPackage.h +65 -65
- package/harmony/fileUpload/src/main/cpp/generated/RNOH/generated/turbo_modules/RNFileupload.cpp +16 -16
- package/harmony/fileUpload/src/main/cpp/generated/RNOH/generated/turbo_modules/RNFileupload.h +16 -16
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/ComponentDescriptors.h +22 -22
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/EventEmitters.cpp +18 -18
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/EventEmitters.h +19 -19
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/Props.cpp +21 -21
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/Props.h +20 -20
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/ShadowNodes.cpp +19 -19
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/ShadowNodes.h +25 -25
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/States.cpp +18 -18
- package/harmony/fileUpload/src/main/cpp/generated/react/renderer/components/react_native_fileupload/States.h +22 -22
- package/harmony/fileUpload/src/main/ets/FileUpLoadModule.ts +109 -106
- package/harmony/fileUpload/src/main/ets/FileUpLoadPackage.ts +46 -46
- package/harmony/fileUpload/src/main/ets/Logger.ts +63 -63
- package/harmony/fileUpload/src/main/ets/generated/components/ts.ts +5 -5
- package/harmony/fileUpload/src/main/ets/generated/index.ets +5 -5
- package/harmony/fileUpload/src/main/ets/generated/ts.ts +6 -6
- package/harmony/fileUpload/src/main/ets/generated/turboModules/RNFileupload.ts +14 -14
- package/harmony/fileUpload/src/main/ets/generated/turboModules/ts.ts +5 -5
- 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 +1 -1
- package/harmony/fileupload.har +0 -0
- package/index.js +1 -1
- package/package.json +51 -43
- package/harmony/fileUpload/OAT.xml +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
## v1.1.1-rc.1
|
|
3
|
-
|
|
4
|
-
### 更新内容
|
|
5
|
-
|
|
6
|
-
- 适配 RN0.77 版本
|
|
7
|
-
- 修改组织名为@react-native-ohos
|
|
1
|
+
# Changelog
|
|
2
|
+
## v1.1.1-rc.1
|
|
3
|
+
|
|
4
|
+
### 更新内容
|
|
5
|
+
|
|
6
|
+
- 适配 RN0.77 版本
|
|
7
|
+
- 修改组织名为@react-native-ohos
|
package/COMMITTERS.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
## Committers列表
|
|
2
|
-
|
|
3
|
-
### 以下是此项目的committer人员
|
|
4
|
-
|
|
5
|
-
不区分先后顺序
|
|
6
|
-
|
|
1
|
+
## Committers列表
|
|
2
|
+
|
|
3
|
+
### 以下是此项目的committer人员
|
|
4
|
+
|
|
5
|
+
不区分先后顺序
|
|
6
|
+
|
|
7
7
|
- [xiafeng_xf_admin](https://gitee.com/xiafeng_xf_admin)
|
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");
|
package/README.OpenSource
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
}
|
|
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,9 +1,9 @@
|
|
|
1
|
-
# @react-native-ohos/react-native-fileupload
|
|
2
|
-
This project is based on [react-native-fileupload V1.1.0](https://github.com/PhilippKrone/react-native-fileupload)
|
|
3
|
-
## Documentation
|
|
4
|
-
[中文](https://
|
|
5
|
-
|
|
6
|
-
[English](https://
|
|
7
|
-
|
|
8
|
-
## License
|
|
9
|
-
This library is licensed under [MIT License (MIT)](https://
|
|
1
|
+
# @react-native-ohos/react-native-fileupload
|
|
2
|
+
This project is based on [react-native-fileupload V1.1.0](https://github.com/PhilippKrone/react-native-fileupload)
|
|
3
|
+
## Documentation
|
|
4
|
+
[中文](https://gitcode.com/CPF-RN/usage-docs/blob/master/zh-cn/react-native-fileupload.md)
|
|
5
|
+
|
|
6
|
+
[English](https://gitcode.com/CPF-RN/usage-docs/blob/master/en/react-native-fileupload.md)
|
|
7
|
+
|
|
8
|
+
## License
|
|
9
|
+
This library is licensed under [MIT License (MIT)](https://gitcode.com/CPF-RN/rntpc_react-native-fileupload/blob/br_rnoh0.77/LICENSE).
|
|
@@ -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,11 +1,11 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"Name": "react-native-fileupload",
|
|
4
|
-
"License": "MIT License",
|
|
5
|
-
"License File": "https://github.com/PhilippKrone/react-native-fileupload/blob/master/LICENSE",
|
|
6
|
-
"Version Number": "1.1.0",
|
|
7
|
-
"Owner" : "Philipp Krone"
|
|
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": "https://github.com/PhilippKrone/react-native-fileupload/blob/master/LICENSE",
|
|
6
|
+
"Version Number": "1.1.0",
|
|
7
|
+
"Owner" : "Philipp Krone"
|
|
8
|
+
"Upstream URL": "https://github.com/PhilippKrone/react-native-fileupload",
|
|
9
|
+
"Description": "A file upload plugin for react-native."
|
|
10
|
+
}
|
|
11
11
|
]
|
|
@@ -1,165 +1,165 @@
|
|
|
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
|
-
|
|
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
165
|
MIT
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"apiType": "stageMode",
|
|
3
|
-
"buildOption": {
|
|
4
|
-
},
|
|
5
|
-
"buildOptionSet": [
|
|
6
|
-
{
|
|
7
|
-
"name": "release",
|
|
8
|
-
"arkOptions": {
|
|
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
|
+
"buildOption": {
|
|
4
|
+
},
|
|
5
|
+
"buildOptionSet": [
|
|
6
|
+
{
|
|
7
|
+
"name": "release",
|
|
8
|
+
"arkOptions": {
|
|
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,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 +1 @@
|
|
|
1
|
-
export * from "./ts";
|
|
1
|
+
export * from "./ts";
|
|
@@ -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
|