Sfoglia il codice sorgente

Merge pull request #9 from aliyun/luozhang

example optimize and  docs
Albert Luo 6 anni fa
parent
commit
59dcaa047f
No account linked to committer's email address
4 ha cambiato i file con 64 aggiunte e 69 eliminazioni
  1. 7
    9
      Example/App.js
  2. 3
    3
      Example/Component/AuthManager.js
  3. 13
    15
      README-CN.md
  4. 41
    42
      README.md

+ 7
- 9
Example/App.js Vedi File

@@ -14,24 +14,22 @@ import { BucketManager } from './Component/BucketManager'
14 14
 import { ObjectManager } from './Component/ObjectManager'
15 15
 
16 16
 import AliyunOSS from 'aliyun-oss-react-native'
17
+
17 18
 //open log 
18 19
 AliyunOSS.enableDevMode()
20
+
19 21
 // defalut configraiton
20 22
 const configuration = {
21 23
    maxRetryCount: 3,  
22 24
    timeoutIntervalForRequest: 30,
23 25
    timeoutIntervalForResource: 24 * 60 * 60
24 26
 };
25
-const config = {
26
-  AccessKey: 'XXX',
27
-  SecretKey: 'XXX',
28
-};
29
-const endPoint = 'oss-cn-zhangjiakou.aliyuncs.com';
30
-const companyserver = "http://XXX:PORT";
31
-const familyserver = "http://XXX:PORT";
32 27
 
33
-// AliyunOSS.initWithPlainTextAccessKey(config.AccessKey, config.SecretKey, endPoint, configuration);
34
-AliyunOSS.initWithServerSTS(familyserver,endPoint, configuration)
28
+const endPoint = 'oss-cn-XXX.aliyuncs.com';
29
+const authserver = "http://XXX:PORT";
30
+
31
+// initWithServerSTS to auth
32
+AliyunOSS.initWithServerSTS(authserver,endPoint, configuration)
35 33
 
36 34
 type Props = {};
37 35
 

+ 3
- 3
Example/Component/AuthManager.js Vedi File

@@ -12,9 +12,9 @@ import {
12 12
 
13 13
 
14 14
 const configuration = {
15
-   maxRetryCount: 3,  
16
-   timeoutIntervalForRequest: 30,
17
-   timeoutIntervalForResource: 24 * 60 * 60
15
+  maxRetryCount: 3,  
16
+  timeoutIntervalForRequest: 30,
17
+  timeoutIntervalForResource: 24 * 60 * 60
18 18
 };
19 19
 
20 20
 const config = {

+ 13
- 15
README-CN.md Vedi File

@@ -139,21 +139,21 @@ AliyunOSS.initWithServerSTS("/***http://ip:端口/****/",endPoint, configuration
139 139
 
140 140
 1. `npm istall`
141 141
 2. 修改config中accessKeyId 和 accessKeySecret
142
-3. node index.js,端口默认9000,鉴权服务地址为:(http|https)://ip.com:9000/
142
+3. node index.js,端口默认9000,鉴权服务地址为:(http|https)://ip:9000/
143 143
 
144 144
 *  step-5:
145 145
 
146 146
 ```javascript
147
-    <!-- 备注:目前接口仅暴漏filePath,上传路径为file:/// -->
148
-    AliyunOSS.asyncUpload(bucketname, objectkey, filePath).then( (res) => {
149
-        <!-- log的查看可以通过React Native自带的调试工具也可通过XCode Log控制台进行查看 -->
150
-        console.log(res)
151
-    }).catch((error)=>{
152
-        console.log(error)
153
-    })
154
-    <!-- 监听上传事件和上传进度-->
155
-   const downloadProgress = p => console.log(p.currentSize / p.totalSize);
156
-   AliyunOSS.addEventListener('uploadProgress', downloadProgress);
147
+  <!-- 备注:目前接口仅暴漏filePath,上传路径为file:/// -->
148
+  AliyunOSS.asyncUpload(bucketname, objectkey, filePath).then( (res) => {
149
+    <!-- log的查看可以通过React Native自带的调试工具也可通过XCode Log控制台进行查看 -->
150
+    console.log(res)
151
+  }).catch((error)=>{
152
+    console.log(error)
153
+  })
154
+  <!-- 监听上传事件和上传进度-->
155
+ const downloadProgress = p => console.log(p.currentSize / p.totalSize);
156
+ AliyunOSS.addEventListener('uploadProgress', downloadProgress);
157 157
 ```
158 158
 
159 159
 ## 接口
@@ -167,9 +167,7 @@ initWithPlainTextAccessKey | 支持| 支持
167 167
 initWithSigner | 支持| 支持
168 168
 initWithSecurityToken | 支持| 支持
169 169
 initWithServerSTS  | 支持| 支持
170
-asyncUpload  | 支持| 支持
171
-asyncAppendObject  ||
172
-asyncResumableUpload  ||
170
+asyncUpload  | 支持| 支持 |
173 171
 initMultipartUpload  | 支持| 支持
174 172
 multipartUpload   | 支持| 支持
175 173
 listParts   | 支持| 支持
@@ -376,7 +374,7 @@ AliyunOSS.asyncListBuckets().then((e) => {
376 374
 
377 375
 ## 示例
378 376
 
379
-仓库Example中提供了React Native android和iOS端运行demo,Android为Example下的android工程,iOS为Example下的NativeAddRN工程,目前Example提供了所有已开发的API DEMO,还在完善中,欢迎参与共建。如何运行Example呢?
377
+仓库Example中提供了React Native android和iOS端运行demo,Android为Example下的android工程,iOS为Example下的iOS工程,目前Example提供了所有已开发的API DEMO,还在完善中,欢迎参与共建。如何运行Example呢?
380 378
 
381 379
 * step-1:克隆项目并安装依赖包
382 380
 

+ 41
- 42
README.md Vedi File

@@ -71,38 +71,39 @@ pod 'aliyun-oss-react-native', :path => '../node_modules/aliyun-oss-react-native
71 71
 
72 72
 #### Android
73 73
 1. Add the following lines to `android/settings.gradle`:
74
-    ```gradle
75
-    include ':react-native-rn-sdk'
76
-    project(':react-native-rn-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/aliyun-oss-rn-sdk/android')
77
-    ```
78 74
 
79
-2. Add the compile line to the dependencies in `android/app/build.gradle`:
80
-    ```gradle
81
-    dependencies {
82
-        compile project(':aliyun-oss-react-native')
83
-    }
84
-    ```
75
+```gradle
76
+include ':react-native-rn-sdk'
77
+project(':react-native-rn-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/aliyun-oss-rn-sdk/android')
78
+```
85 79
 
80
+2. Add the compile line to the dependencies in `android/app/build.gradle`:
81
+```gradle
82
+dependencies {
83
+  compile project(':aliyun-oss-react-native')
84
+}
85
+```
86 86
 3. Add the required permissions in `AndroidManifest.xml`:
87
-    ```xml
88
-       <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
89
-       <uses-permission android:name="android.permission.CAMERA" />
90
-    ```
87
+
88
+  ```xml
89
+     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
90
+     <uses-permission android:name="android.permission.CAMERA" />
91
+  ```
91 92
 4. Add the import and link the package in `MainApplication.java`:
92 93
 
93
-    ```java
94
-      import com.reactlibrary.RNAliyunOssPackage;
94
+```java
95
+import com.reactlibrary.RNAliyunOssPackage;
95 96
 
96
-       public class MainApplication extends Application implements ReactApplication {
97
-        @Override
98
-          protected List<ReactPackage> getPackages() {
99
-            return Arrays.<ReactPackage>asList(
100
-                new MainReactPackage(),
101
-                  new RNAliyunOssPackage()
102
-            );
103
-          }
104
-       }
105
-      ```
97
+ public class MainApplication extends Application implements ReactApplication {
98
+  @Override
99
+    protected List<ReactPackage> getPackages() {
100
+      return Arrays.<ReactPackage>asList(
101
+        new MainReactPackage(),
102
+        new RNAliyunOssPackage()
103
+    );
104
+  }
105
+}
106
+```
106 107
 
107 108
 ## Usage
108 109
 
@@ -170,8 +171,6 @@ initWithSigner  |Y|Y
170 171
 initWithSecurityToken   |Y|Y
171 172
 initWithServerSTS   |Y|Y
172 173
 asyncUpload   |Y| Y
173
-asyncAppendObject  ||
174
-asyncResumableUpload  ||
175 174
 initMultipartUpload |Y|Y
176 175
 multipartUpload  | Y | Y
177 176
 listParts |Y|Y
@@ -347,29 +346,29 @@ AliyunOSS.asyncListBuckets().then((e) => {
347 346
 ```
348 347
 ### doesObjectExist
349 348
 
350
-```
351
- AliyunOSS.doesObjectExist('luozhang001','xx.png').then((e)=>{
349
+```javascript
350
+ AliyunOSS.doesObjectExist('luozhang001','xx.png').then( (e) => {
351
+    console.log(e)
352
+  }).catch((e) => {
352 353
     console.log(e)
353
-  }).catch((e)=>{
354
-     console.log(e)
355 354
   })
356 355
 ```
357 356
 
358 357
 ### asyncCopyObject
359 358
 
360
-```
361
- AliyunOSS.asyncCopyObject('luozhang001',"2.png","luozhang002","sbsbsb").then((e)=>{
362
-      console.log(e)
363
-    }).catch((e)=>{
364
-      console.log("xxxx")
365
-      console.log(e)
366
-    })
359
+```javascript
360
+ AliyunOSS.asyncCopyObject('luozhang001',"2.png","luozhang002","sbsbsb").then( (e) => {
361
+    console.log(e)
362
+  }).catch((e)=>{
363
+    console.log("xxxx")
364
+    console.log(e)
365
+  })
367 366
 ```
368 367
 ### asyncDeleteObject
369 368
 
370
-```
369
+```javascript
371 370
  AliyunOSS.asyncDeleteObject('luozhang001','2.png').then((e)=>{
372
-     Alert.alert(e)
371
+    Alert.alert(e)
373 372
   }).catch((e)=>{
374 373
     console.log(e)
375 374
   })
@@ -377,7 +376,7 @@ AliyunOSS.asyncListBuckets().then((e) => {
377 376
 
378 377
 ## DEMO
379 378
 
380
-In the repository, we prodive RN SDK DEMO in the Example folder including andriod and ios,`Example/android` provide the android demo;`Example/NativeAddRN` provide the ios demo.Welcome to join us, how to run the Example ?
379
+In the repository, we prodive RN SDK DEMO in the Example folder including andriod and ios,`Example/android` provide the android demo;`Example/iOS` provide the ios demo.Welcome to join us, how to run the Example ?
381 380
 
382 381
 * step-1:clone the project and install some dependencies
383 382