|
@@ -32,6 +32,61 @@ const dirs = RNFetchBlob.fs.dirs
|
32
|
32
|
|
33
|
33
|
let prefix = ((Platform.OS === 'android') ? 'file://' : '')
|
34
|
34
|
|
|
35
|
+describe('cache control header and range request test', (report, done) => {
|
|
36
|
+
|
|
37
|
+ let image = RNTest.prop('image')
|
|
38
|
+ let part = [
|
|
39
|
+ `${fs.dirs.DocumentDir}/cache-control-test-part1.png`,
|
|
40
|
+ `${fs.dirs.DocumentDir}/cache-control-test-part2.png`,
|
|
41
|
+ `${fs.dirs.DocumentDir}/cache-control-test-part3.png`
|
|
42
|
+ ]
|
|
43
|
+ let tmp = null
|
|
44
|
+
|
|
45
|
+ RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
|
|
46
|
+ Authorization : `Bearer ${DROPBOX_TOKEN}`,
|
|
47
|
+ 'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+FILENAME+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
|
|
48
|
+ 'Content-Type' : 'application/octet-stream',
|
|
49
|
+ }, image)
|
|
50
|
+ .then((resp) => {
|
|
51
|
+ resp = resp.json()
|
|
52
|
+ report(
|
|
53
|
+ <Assert key="confirm the file has been uploaded" expect={FILENAME} actual={resp.name}/>
|
|
54
|
+ )
|
|
55
|
+ return RNFetchBlob.config({
|
|
56
|
+ path : part[0],
|
|
57
|
+ })
|
|
58
|
+ .fetch('GET', 'https://content.dropboxapi.com/1/files/auto/rn-upload/' + FILENAME, {
|
|
59
|
+ Authorization : `Bearer ${DROPBOX_TOKEN}`,
|
|
60
|
+ 'Cache-Control' : 'no-store',
|
|
61
|
+ 'Range' : 'bytes=0-23000'
|
|
62
|
+ })
|
|
63
|
+ })
|
|
64
|
+ .then((res) => {
|
|
65
|
+ let size = Math.floor(res.info().headers['Content-Length'])
|
|
66
|
+ report(<Assert key="part2 content length = 23001" expect={23001} actual={size}/>)
|
|
67
|
+ return RNFetchBlob.config({
|
|
68
|
+ path : part[2]
|
|
69
|
+ })
|
|
70
|
+ .fetch('GET', 'https://content.dropboxapi.com/1/files/auto/rn-upload/' + FILENAME, {
|
|
71
|
+ Authorization : `Bearer ${DROPBOX_TOKEN}`,
|
|
72
|
+ 'Range' : 'bytes=23001-23975',
|
|
73
|
+ 'Cache-Control' : 'no-store'
|
|
74
|
+ })
|
|
75
|
+ })
|
|
76
|
+ .then((res) => {
|
|
77
|
+ let size = Math.floor(res.info().headers['Content-Length'])
|
|
78
|
+ report(<Assert key="part3 content length = 975" expect={974} actual={size}/>)
|
|
79
|
+ return fs.appendFile(part[0], part[2], 'uri')
|
|
80
|
+ })
|
|
81
|
+ .then((written) => {
|
|
82
|
+ return fs.stat(part[0])
|
|
83
|
+ })
|
|
84
|
+ .then((stat) => {
|
|
85
|
+ report(<Assert key="combined file size check" expect="23975" actual={stat.size}/>)
|
|
86
|
+ done()
|
|
87
|
+ })
|
|
88
|
+})
|
|
89
|
+
|
35
|
90
|
describe('#73 unicode response BASE64 content test', (report, done) => {
|
36
|
91
|
|
37
|
92
|
fetch(`${TEST_SERVER_URL}/unicode`, {
|