|
@@ -7,6 +7,7 @@ import {
|
7
|
7
|
Text,
|
8
|
8
|
View,
|
9
|
9
|
ScrollView,
|
|
10
|
+ Platform,
|
10
|
11
|
Dimensions,
|
11
|
12
|
Image,
|
12
|
13
|
} from 'react-native';
|
|
@@ -14,6 +15,8 @@ import {
|
14
|
15
|
const { Assert, Comparer, Info, describe, prop } = RNTest
|
15
|
16
|
const { TEST_SERVER_URL, FILENAME, DROPBOX_TOKEN, styles } = prop()
|
16
|
17
|
|
|
18
|
+let prefix = ((Platform.OS === 'android') ? 'file://' : '')
|
|
19
|
+
|
17
|
20
|
// added after 0.5.0
|
18
|
21
|
|
19
|
22
|
describe('Get storage folders', (report, done) => {
|
|
@@ -47,7 +50,9 @@ describe('Download file to storage with custom file extension', (report, done) =
|
47
|
50
|
.then((resp) => {
|
48
|
51
|
tmpFilePath = resp.path()
|
49
|
52
|
report(<Info key={`image from ${tmpFilePath}`}>
|
50
|
|
- <Image source={{ uri : tmpFilePath}} style={styles.image}/>
|
|
53
|
+ <Image
|
|
54
|
+ source={{ uri : prefix + tmpFilePath}}
|
|
55
|
+ style={styles.image}/>
|
51
|
56
|
</Info>)
|
52
|
57
|
done()
|
53
|
58
|
})
|
|
@@ -60,8 +65,13 @@ describe('Read cached file via file stream', (report, done) => {
|
60
|
65
|
data += chunk
|
61
|
66
|
})
|
62
|
67
|
stream.onEnd(() => {
|
|
68
|
+ console.log(prop('image').length, data.length)
|
|
69
|
+ console.log(data)
|
63
|
70
|
report(
|
64
|
|
- <Assert key="image should have value" expect={0} comparer={Comparer.smaller} actual={data.length}/>,
|
|
71
|
+ <Assert key="image should have value"
|
|
72
|
+ expect={0}
|
|
73
|
+ comparer={Comparer.smaller}
|
|
74
|
+ actual={data.length}/>,
|
65
|
75
|
<Info key="image from read stream">
|
66
|
76
|
<Image source={{uri : data}} style={styles.image}/>
|
67
|
77
|
</Info>)
|
|
@@ -85,32 +95,33 @@ describe('File stream reader error should be able to handled', (report, done) =>
|
85
|
95
|
})
|
86
|
96
|
})
|
87
|
97
|
|
88
|
|
-describe('Upload from file storage', (report, done) => {
|
89
|
|
- let filename = ''
|
90
|
|
- let filepath = ''
|
91
|
|
- RNFetchBlob.getSystemDirs().then((dirs) => {
|
92
|
|
- filename = 'ios.5.0-' + Date.now() + '-from-storage.png'
|
93
|
|
- filepath = dirs.DocumentDir + '/' + filename
|
94
|
|
- return RNFetchBlob.config({ path : filepath })
|
95
|
|
- .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
|
96
|
|
- })
|
97
|
|
- .then((resp) => {
|
98
|
|
- let path = resp.path()
|
99
|
|
- return RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
|
100
|
|
- Authorization : `Bearer ${DROPBOX_TOKEN}`,
|
101
|
|
- 'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+filename+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
|
102
|
|
- 'Content-Type' : 'application/octet-stream',
|
103
|
|
- }, 'RNFetchBlob-file://' + path)
|
104
|
|
- .then((resp) => {
|
105
|
|
- console.log(resp.text())
|
106
|
|
- resp = resp.json()
|
107
|
|
- report(
|
108
|
|
- <Assert key="confirm the file has been uploaded" expect={filename} actual={resp.name}/>
|
109
|
|
- )
|
110
|
|
- done()
|
111
|
|
- })
|
112
|
|
- })
|
113
|
|
-
|
114
|
|
-
|
115
|
|
-
|
116
|
|
-})
|
|
98
|
+//
|
|
99
|
+// describe('Upload from file storage', (report, done) => {
|
|
100
|
+// let filename = ''
|
|
101
|
+// let filepath = ''
|
|
102
|
+// RNFetchBlob.getSystemDirs().then((dirs) => {
|
|
103
|
+// filename = 'ios.5.0-' + Date.now() + '-from-storage.png'
|
|
104
|
+// filepath = dirs.DocumentDir + '/' + filename
|
|
105
|
+// return RNFetchBlob.config({ path : filepath })
|
|
106
|
+// .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
|
|
107
|
+// })
|
|
108
|
+// .then((resp) => {
|
|
109
|
+// let path = resp.path()
|
|
110
|
+// return RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
|
|
111
|
+// Authorization : `Bearer ${DROPBOX_TOKEN}`,
|
|
112
|
+// 'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+filename+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
|
|
113
|
+// 'Content-Type' : 'application/octet-stream',
|
|
114
|
+// }, 'RNFetchBlob-file://' + path)
|
|
115
|
+// .then((resp) => {
|
|
116
|
+// console.log(resp.text())
|
|
117
|
+// resp = resp.json()
|
|
118
|
+// report(
|
|
119
|
+// <Assert key="confirm the file has been uploaded" expect={filename} actual={resp.name}/>
|
|
120
|
+// )
|
|
121
|
+// done()
|
|
122
|
+// })
|
|
123
|
+// })
|
|
124
|
+//
|
|
125
|
+//
|
|
126
|
+//
|
|
127
|
+// })
|