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

Commit a1b9dcc

Browse files
committed
merge 0.9.7
1 parent 7bc952c commit a1b9dcc

File tree

12 files changed

+91
-56
lines changed

12 files changed

+91
-56
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ function fetch(...args:any):Promise {
241241
console.log(e , 'EXPIRED!!')
242242
if(e.taskId === taskId && promise.onExpire) {
243243
promise.onExpire(e)
244+
}
245+
})
244246

245247
partEvent = emitter.addListener('RNFetchBlobServerPush', (e) => {
246248
if(e.taskId === taskId && promise.onPartData) {

src/ios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const RNFetchBlob:RNFetchBlobNative = NativeModules.RNFetchBlob
2020
*/
2121
function openDocument(path:string, scheme:string) {
2222
if(Platform.OS === 'ios')
23-
return RNFetchBlob.openDocument(path, scheme)
23+
return RNFetchBlob.openDocument('file://' + path, scheme)
2424
else
2525
return Promise.reject('RNFetchBlob.openDocument only supports IOS.')
2626
}
@@ -33,7 +33,7 @@ function openDocument(path:string, scheme:string) {
3333
*/
3434
function previewDocument(path:string, scheme:string) {
3535
if(Platform.OS === 'ios')
36-
return RNFetchBlob.previewDocument(path, scheme)
36+
return RNFetchBlob.previewDocument('file://' + path, scheme)
3737
else
3838
return Promise.reject('RNFetchBlob.previewDocument only supports IOS.')
3939
}

src/ios/RNFetchBlobNetwork.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ @interface RNFetchBlobNetwork ()
4242
{
4343
BOOL * respFile;
4444
BOOL isNewPart;
45+
BOOL * isIncrement;
4546
NSMutableData * partBuffer;
4647
NSString * destPath;
4748
NSOutputStream * writeStream;
@@ -562,6 +563,7 @@ - (void) URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthentica
562563
}
563564
}
564565

566+
565567
- (void) URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session
566568
{
567569
NSLog(@"sess done in background");

test-server/public/json-dummy-1.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name" : "fetchblob-dev"
3+
}

test-server/server.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ app.use(function(req, res, next) {
6666
next();
6767
})
6868

69+
70+
app.get('/10s-download', (req,res) => {
71+
var count = 0
72+
var data = ''
73+
for(var i =0;i<1024000;i++)
74+
data += '1'
75+
res.set('Contet-Length', 1024000*10)
76+
var it = setInterval(() => {
77+
res.write(data)
78+
count++
79+
if(count == 10) {
80+
clearInterval(it)
81+
res.end()
82+
}
83+
}, 1000)
84+
})
85+
6986
app.get('/video/:count', (req, res) => {
7087
var count = 0
7188
res.set('Content-Type', 'multipart/x-mixed-replace; boundary="---osclivepreview---"')

test-server/test.jpeg

Lines changed: 1 addition & 0 deletions
Loading

test/test-0.10.0.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('issue #102', (report, done) => {
7878
.fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
7979
.then((res) => {
8080
tmp = res
81-
RNFetchBlob.ios.previewDocument('file://' + res.path(), 'itms-books:')
81+
RNFetchBlob.ios.previewDocument(res.path())
8282
return RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {},
8383
[{ name : String(1), data : RNFetchBlob.wrap(res.path()), filename: '#102-test-image.png' }])
8484
})

test/test-0.6.2.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe('upload asset from camera roll', (report, done) => {
6262

6363
describe('Upload multipart data with file from CameraRoll', (report, done) => {
6464
let filename = 'test-from-storage-img-'+Date.now()+'.png'
65+
console.log(photo)
6566
RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
6667
'Content-Type' : 'multipart/form-data',
6768
}, [
@@ -165,10 +166,11 @@ describe('upload file from assets',(report, done) => {
165166
let assetName = fs.asset('test-asset1.json')
166167
RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
167168
Authorization : `Bearer ${DROPBOX_TOKEN}`,
168-
'Dropbox-API-Arg': `{\"path\": \"/rn-upload/file-from-asset-${Platform.OS}.json\",\"mode\": \"add\",\"autorename\": false,\"mute\": false}`,
169+
'Dropbox-API-Arg': `{\"path\": \"/rn-upload/file-from-asset-${Platform.OS}.json\",\"mode\": \"overwrite\",\"autorename\": false,\"mute\": false}`,
169170
'Content-Type' : 'application/octet-stream',
170171
}, RNFetchBlob.wrap(assetName))
171172
.then((resp) => {
173+
console.log(resp)
172174
resp = resp.json()
173175
report(
174176
<Assert key="file name check"

test/test-0.9.4.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import {
1414

1515
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
1616
window.Blob = RNFetchBlob.polyfill.Blob
17+
window.fetch = new RNFetchBlob.polyfill.Fetch({
18+
auto : true,
19+
binaryContentTypes : ['image/', 'video/', 'audio/']
20+
}).build()
1721

1822
const fs = RNFetchBlob.fs
1923
const { Assert, Comparer, Info, prop } = RNTest
@@ -56,15 +60,17 @@ describe('issue #106', (report, done) => {
5660
return res.json()
5761
})
5862
.then((data) => {
59-
// console.log(data)
63+
console.log(data)
6064
report(<Assert key="fetch request success" expect={20000} actual={data.total}/>)
6165
done()
6266
})
6367

6468
})
6569

6670
describe('issue #111 get redirect destination', (report, done) => {
67-
RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/redirect`)
71+
RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/redirect`, {
72+
'Cache-Control' : 'no-store'
73+
})
6874
.then((res) => {
6975
console.log(res.info())
7076
report(

test/test-0.9.5.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ let prefix = ((Platform.OS === 'android') ? 'file://' : '')
3030

3131
describe('issue #122 force response data format', (report, done) => {
3232

33-
RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/json-dummy.json`, {
33+
RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/json-dummy-1.json`, {
3434
'RNFB-Response' : 'base64'
3535
})
3636
.then((res) => {
3737
let r = RNFetchBlob.base64.decode(res.data)
3838
report(
3939
<Assert key="test data verify" expect="fetchblob-dev" actual={JSON.parse(r).name}/>,
4040
<Assert key="should successfully decode the data" expect={true} actual={true}/>)
41-
return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/json-dummy.json`)
41+
return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/json-dummy-1.json`)
4242
})
4343
.then((res) => {
4444
report(
@@ -79,7 +79,7 @@ describe('#129 memory leaking when enable uploadProgress', (report, done) => {
7979

8080
})
8181

82-
false && describe('#131 status code != 200 should not throw an error', (report, done) => {
82+
describe('#131 status code != 200 should not throw an error', (report, done) => {
8383

8484
let count = 0
8585
let codes = [404, 500, 501, 403]

0 commit comments

Comments
 (0)