Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit c36980c

Browse files
committed
Merge branch 'master' into 0.6.0
2 parents 2a80b5b + 6873562 commit c36980c

File tree

7 files changed

+50
-8
lines changed

7 files changed

+50
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ A `session` is an object that helps you manage files. It simply maintains a list
875875

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fetchblob",
3-
"version": "0.5.7",
3+
"version": "0.6.0",
44
"private": true,
55
"scripts": {
66
"start": "node node_modules/react-native/local-cli/cli.js start",

src/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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)
22

33
A module provides upload, download, and files access API. Supports file stream read/write for process large files.
44

@@ -304,7 +304,7 @@ In `version >= 0.4.2` it is possible to know the upload/download progress.
304304

305305
#### Android Media Scanner, and Downloads App Support
306306

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`.
308308

309309

310310
```js
@@ -851,6 +851,7 @@ A `session` is an object that helps you manage files. It simply maintains a list
851851

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

src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ else if(type == "form")
157157
break;
158158
case "put" :
159159
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);
161161
else
162-
req.post(ctx, url, entity, "multipart/form-data", handler);
162+
req.put(ctx, url, entity, "multipart/form-data", handler);
163163
break;
164164
case "delete" :
165165
req.delete(url, handler);

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-fetch-blob",
3-
"version": "0.5.7",
3+
"version": "0.5.8",
44
"description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
55
"main": "index.js",
66
"scripts": {

test-server/server.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,17 @@ app.all('/params', function(req, res) {
7979
app.all('/empty', function(req, res) {
8080
res.send('')
8181
})
82+
83+
app.delete('/hey', function(req, res) {
84+
res.send('man')
85+
})
86+
8287
// 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) {
8493
console.log(req.headers)
8594
console.log(req.body)
8695
console.log(req.files)
@@ -94,7 +103,7 @@ app.post('/upload-form', function(req, res) {
94103
fields : req.body,
95104
files : req.files
96105
})
97-
})
106+
}
98107

99108
function watch(source, dest, ignore) {
100109
// watch files in test folder

test/test-0.1.x-0.4.x.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,34 @@ describe('Progress report test', (report, done) => {
114114
})
115115

116116
})
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+
})

0 commit comments

Comments
 (0)