Browse Source

Merge branch 'master' into 0.6.0

Ben Hsieh 8 years ago
parent
commit
c36980c6cb

+ 1
- 0
README.md View File

875
 
875
 
876
 | Version | |
876
 | Version | |
877
 |---|---|
877
 |---|---|
878
+| 0.5.8 | Fix #33 PUT request will always be sent as POST on Android |
878
 | 0.5.7 | Fix #31 #30 Xcode pre 7.3 build error |
879
 | 0.5.7 | Fix #31 #30 Xcode pre 7.3 build error |
879
 | 0.5.6 | Add support for IOS network status indicator. Fix file stream ASCII reader bug. |
880
 | 0.5.6 | Add support for IOS network status indicator. Fix file stream ASCII reader bug. |
880
 | 0.5.5 | Remove work in progress code added in 0.5.2 which may cause memory leaks. |
881
 | 0.5.5 | Remove work in progress code added in 0.5.2 which may cause memory leaks. |

+ 1
- 1
package.json View File

1
 {
1
 {
2
   "name": "fetchblob",
2
   "name": "fetchblob",
3
-  "version": "0.5.7",
3
+  "version": "0.6.0",
4
   "private": true,
4
   "private": true,
5
   "scripts": {
5
   "scripts": {
6
     "start": "node node_modules/react-native/local-cli/cli.js start",
6
     "start": "node node_modules/react-native/local-cli/cli.js start",

+ 3
- 2
src/README.md View File

1
-# react-native-fetch-blob [![npm version](https://img.shields.io/badge/npm package-0.5.7-brightgreen.svg)](https://badge.fury.io/js/react-native-fetch-blob) ![](https://img.shields.io/badge/PR-Welcome-brightgreen.svg) ![](https://img.shields.io/badge/in progress-0.6.0-yellow.svg)
1
+# react-native-fetch-blob [![npm version](https://img.shields.io/badge/npm package-0.5.8-brightgreen.svg)](https://badge.fury.io/js/react-native-fetch-blob) ![](https://img.shields.io/badge/PR-Welcome-brightgreen.svg) ![](https://img.shields.io/badge/in progress-0.6.0-yellow.svg)
2
 
2
 
3
 A module provides upload, download, and files access API. Supports file stream read/write for process large files.
3
 A module provides upload, download, and files access API. Supports file stream read/write for process large files.
4
 
4
 
304
 
304
 
305
 #### Android Media Scanner, and Downloads App Support
305
 #### Android Media Scanner, and Downloads App Support
306
 
306
 
307
-If you want to make a file in `External Storage` becomes visible in Picture, Misuc, or other built-in apps, you will have to use `Media Scanner`. To make this happend, use `scanFile` method in `fs`.
307
+If you want to make a file in `External Storage` becomes visible in Picture, Music, or other built-in apps, you will have to use `Media Scanner`. To make this happend, use `scanFile` method in `fs`.
308
 
308
 
309
 
309
 
310
 ```js
310
 ```js
851
 
851
 
852
 | Version | |
852
 | Version | |
853
 |---|---|
853
 |---|---|
854
+| 0.5.8 | Fix #33 PUT request will always be sent as POST on Android |
854
 | 0.5.7 | Fix #31 #30 Xcode pre 7.3 build error |
855
 | 0.5.7 | Fix #31 #30 Xcode pre 7.3 build error |
855
 | 0.5.6 | Add support for IOS network status indicator. Fix file stream ASCII reader bug. |
856
 | 0.5.6 | Add support for IOS network status indicator. Fix file stream ASCII reader bug. |
856
 | 0.5.5 | Remove work in progress code added in 0.5.2 which may cause memory leaks. |
857
 | 0.5.5 | Remove work in progress code added in 0.5.2 which may cause memory leaks. |

+ 2
- 2
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java View File

157
                     break;
157
                     break;
158
                 case "put" :
158
                 case "put" :
159
                     if(this.type == null || this.type.equalsIgnoreCase("octet"))
159
                     if(this.type == null || this.type.equalsIgnoreCase("octet"))
160
-                        req.post(ctx, url, entity, "application/octet-stream", handler);
160
+                        req.put(ctx, url, entity, "application/octet-stream", handler);
161
                     else
161
                     else
162
-                        req.post(ctx, url, entity, "multipart/form-data", handler);
162
+                        req.put(ctx, url, entity, "multipart/form-data", handler);
163
                     break;
163
                     break;
164
                 case "delete" :
164
                 case "delete" :
165
                     req.delete(url, handler);
165
                     req.delete(url, handler);

+ 1
- 1
src/package.json View File

1
 {
1
 {
2
   "name": "react-native-fetch-blob",
2
   "name": "react-native-fetch-blob",
3
-  "version": "0.5.7",
3
+  "version": "0.5.8",
4
   "description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
4
   "description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
5
   "main": "index.js",
5
   "main": "index.js",
6
   "scripts": {
6
   "scripts": {

+ 11
- 2
test-server/server.js View File

79
 app.all('/empty', function(req, res) {
79
 app.all('/empty', function(req, res) {
80
   res.send('')
80
   res.send('')
81
 })
81
 })
82
+
83
+app.delete('/hey', function(req, res) {
84
+  res.send('man')
85
+})
86
+
82
 // handle multipart/form-data request
87
 // handle multipart/form-data request
83
-app.post('/upload-form', function(req, res) {
88
+app.post('/upload-form', formUpload)
89
+
90
+app.put('/upload-form', formUpload)
91
+
92
+function formUpload(req, res) {
84
   console.log(req.headers)
93
   console.log(req.headers)
85
   console.log(req.body)
94
   console.log(req.body)
86
   console.log(req.files)
95
   console.log(req.files)
94
     fields : req.body,
103
     fields : req.body,
95
     files : req.files
104
     files : req.files
96
   })
105
   })
97
-})
106
+}
98
 
107
 
99
 function watch(source, dest, ignore) {
108
 function watch(source, dest, ignore) {
100
   // watch files in  test folder
109
   // watch files in  test folder

+ 31
- 0
test/test-0.1.x-0.4.x.js View File

114
     })
114
     })
115
 
115
 
116
 })
116
 })
117
+
118
+
119
+describe('PUT request test', (report, done) => {
120
+
121
+  RNFetchBlob.fetch('PUT', `${TEST_SERVER_URL}/upload-form`, {
122
+      Authorization : "Bearer fsXcpmKPrHgAAAAAAAAAEGxFXwhejXM_E8fznZoXPhHbhbNhA-Lytbe6etp1Jznz",
123
+      'Content-Type' : 'multipart/form-data',
124
+    }, [
125
+      { name : 'test-img', filename : 'test-img.png', data: image},
126
+      { name : 'test-text', filename : 'test-text.txt', data: RNFetchBlob.base64.encode('hello.txt')},
127
+      { name : 'field1', data : 'hello !!'},
128
+      { name : 'field2', data : 'hello2 !!'}
129
+    ])
130
+  .then((resp) => {
131
+    resp = resp.json()
132
+    report(
133
+      <Assert key="check put form data #1" expect="hello !!" actual={resp.fields.field1}/>,
134
+      <Assert key="check put form data #2" expect="hello2 !!" actual={resp.fields.field2}/>,
135
+    )
136
+    done()
137
+  })
138
+})
139
+
140
+describe('DELETE request test', (report, done) => {
141
+  RNFetchBlob.fetch('DELETE', `${TEST_SERVER_URL}/hey`)
142
+  .then((resp) => {
143
+    report(
144
+      <Assert key="check DELETE request result" expect={'man'} actual={resp.text()}/>)
145
+      done()
146
+  })
147
+})