Skip to content

Commit 6860e84

Browse files
committed
Implemented demo app tests
1 parent d160cff commit 6860e84

File tree

10 files changed

+377
-86
lines changed

10 files changed

+377
-86
lines changed

RNFetchBlobWin/App.js

Lines changed: 248 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ import {
2222

2323
import {
2424
Colors,
25-
DebugInstructions,
26-
ReloadInstructions,
2725
} from 'react-native/Libraries/NewAppScreen';
2826

2927
import RNFetchBlob from 'rn-fetch-blob';
30-
31-
3228

3329
const App: () => React$Node = () => {
3430

@@ -41,6 +37,16 @@ const App: () => React$Node = () => {
4137

4238
const [unlinkParam, setUnlinkParam] = useState('');
4339

40+
const [statParam, setStatParam] = useState('');
41+
42+
const [mkdirParam, setMkdirParam] = useState('');
43+
const [mkdirURIParam, setMkdirURIParam] = useState('');
44+
45+
const [readParam, setReadParam] = useState('');
46+
47+
const [hashPathParam, setHashPathParam] = useState('');
48+
const [hashAlgValue, setHashAlgValue] = useState('md5');
49+
4450
// Methods ********************************************************************
4551
// exists()
4652
const existsCall = () => {
@@ -118,6 +124,105 @@ const App: () => React$Node = () => {
118124
})
119125
}
120126

127+
// stat(), lstat()
128+
const statCall = () => {
129+
RNFetchBlob.fs.stat(RNFetchBlob.fs.dirs.DocumentDir + '/' + statParam)
130+
.then((stats) => {
131+
console.log(stats);
132+
Alert.alert("stat() result (others logged in console)",
133+
"filename: " + stats.filename +
134+
"\nlastModified: " + stats.lastModified +
135+
"\npath: " + stats.path +
136+
"\nsize: " + stats.size +
137+
"\ntype: " + stats.type)
138+
})
139+
.catch((err) => {
140+
Alert.alert(err.message);
141+
})
142+
}
143+
144+
const lstatCall = () => {
145+
RNFetchBlob.fs.lstat(RNFetchBlob.fs.dirs.DocumentDir + '/' + statParam)
146+
.then((stats) => {
147+
console.log(stats);
148+
Alert.alert("lstat() result (others logged in console)", "filename: " + stats[0].filename +
149+
"\nlastModified: " + stats[0].lastModified +
150+
"\npath: " + stats[0].path +
151+
"\nsize: " + stats[0].size +
152+
"\ntype: " + stats[0].type);
153+
})
154+
.catch((err) => {
155+
Alert.alert(err.message);
156+
})
157+
}
158+
159+
// mkdir()
160+
const mkdirCall = () => {
161+
if(mkdirParam.length > 0)
162+
{
163+
RNFetchBlob.fs.mkdir(RNFetchBlob.fs.dirs.DocumentDir + '/' + mkdirParam)
164+
.then(() => {
165+
Alert.alert('successfully created file:', RNFetchBlob.fs.dirs.DocumentDir + '/' + mkdirParam);
166+
})
167+
.catch((err) => {
168+
Alert.alert(err.message);
169+
})
170+
}
171+
else {
172+
Alert.alert('Cannot make file with no name provided')
173+
}
174+
}
175+
176+
// createFile()
177+
const createFileUTF8Call = () => {
178+
RNFetchBlob.fs.createFile(RNFetchBlob.fs.dirs.DocumentDir + '/' + mkdirParam, 'foo', 'utf8');
179+
}
180+
181+
const createFileASCIICall = () => {
182+
RNFetchBlob.fs.createFile(RNFetchBlob.fs.dirs.DocumentDir + '/' + mkdirParam, [102, 111, 111], 'ascii');
183+
}
184+
185+
const createFileBase64Call = () => {
186+
RNFetchBlob.fs.createFile(RNFetchBlob.fs.dirs.DocumentDir + '/' + mkdirParam, 'Zm9v', 'base64');
187+
}
188+
189+
const createFileURICall = () => {
190+
RNFetchBlob.fs.createFile(RNFetchBlob.fs.dirs.DocumentDir + '/' + mkdirParam, RNFetchBlob.fs.dirs.DocumentDir + '/' + mkdirURIParam, 'uri');
191+
}
192+
193+
// readFile()
194+
const readFileUTF8Call = () => {
195+
RNFetchBlob.fs.readFile(RNFetchBlob.fs.dirs.DocumentDir + '/' + readParam, 'utf8')
196+
.then((data) => {
197+
Alert.alert('UTF8 result of ' + readParam, data);
198+
});
199+
}
200+
201+
const readFileASCIICall = () => {
202+
RNFetchBlob.fs.readFile(RNFetchBlob.fs.dirs.DocumentDir + '/' + readParam, 'ascii')
203+
.then((data) => {
204+
Alert.alert('UTF8 result of ' + readParam, data);
205+
});
206+
}
207+
208+
const readFileBase64Call = () => {
209+
RNFetchBlob.fs.readFile(RNFetchBlob.fs.dirs.DocumentDir + '/' + readParam, 'base64')
210+
.then((data) => {
211+
Alert.alert('UTF8 result of ' + readParam, data);
212+
})
213+
}
214+
215+
// hash()
216+
const hashCall = () => {
217+
RNFetchBlob.fs.hash(RNFetchBlob.fs.dirs.DocumentDir + '/' + hashPathParam, hashAlgValue)
218+
.then((hash) => {
219+
Alert.alert(hashAlgValue, hash);
220+
})
221+
.catch((err) => {
222+
console.log(hashAlgValue + ': ' + err);
223+
});
224+
}
225+
121226
// App ************************************************************************
122227
return (
123228
<>
@@ -262,7 +367,145 @@ const App: () => React$Node = () => {
262367
onPress={unlinkCall}
263368
/>
264369
</View>
265-
</View>
370+
</View>
371+
372+
<View style={styles.body}>
373+
<View style={styles.sectionContainer}>
374+
<Text style={styles.sectionTitle}>
375+
{"stat - stat(), lstat()"}
376+
</Text>
377+
<View style={styles.sectionDescription}>
378+
<TextInput style = {styles.input}
379+
placeholder = "Source path"
380+
onChangeText={statParam => setStatParam(statParam)}
381+
placeholderTextColor = "#9a73ef"
382+
autoCapitalize = "none"
383+
/>
384+
</View>
385+
<Button
386+
title="stat Call"
387+
color="#9a73ef"
388+
onPress={statCall}
389+
/>
390+
<Button
391+
title="lstat Call"
392+
color="#9a73ef"
393+
onPress={lstatCall}
394+
/>
395+
</View>
396+
</View>
397+
398+
<View style={styles.body}>
399+
<View style={styles.sectionContainer}>
400+
<Text style={styles.sectionTitle}>
401+
{"mkdir - mkdir(), createFile()"}
402+
</Text>
403+
<View style={styles.sectionDescription}>
404+
<TextInput style = {styles.input}
405+
placeholder = "Source path"
406+
onChangeText={mkdirParam => setMkdirParam(mkdirParam)}
407+
placeholderTextColor = "#9a73ef"
408+
autoCapitalize = "none"
409+
/>
410+
<TextInput style = {styles.input}
411+
placeholder = "URI source path"
412+
onChangeText={mkdirURIParam => setMkdirURIParam(mkdirURIParam)}
413+
placeholderTextColor = "#9a73ef"
414+
autoCapitalize = "none"
415+
/>
416+
</View>
417+
<Button
418+
title="mkdir"
419+
color="#9a73ef"
420+
onPress={mkdirCall}
421+
/>
422+
<Button
423+
title="Create UTF8 file"
424+
color="#9a73ef"
425+
onPress={createFileUTF8Call}
426+
/>
427+
<Button
428+
title="Create ASCII file"
429+
color="#9a73ef"
430+
onPress={createFileASCIICall}
431+
/>
432+
<Button
433+
title="Create base64 file"
434+
color="#9a73ef"
435+
onPress={createFileBase64Call}
436+
/>
437+
<Button
438+
title="Create file from URI"
439+
color="#9a73ef"
440+
onPress={createFileURICall}
441+
/>
442+
</View>
443+
</View>
444+
445+
<View style={styles.body}>
446+
<View style={styles.sectionContainer}>
447+
<Text style={styles.sectionTitle}>
448+
{"readFile - readFile()"}
449+
</Text>
450+
<View style={styles.sectionDescription}>
451+
<TextInput style = {styles.input}
452+
placeholder = "Source path"
453+
onChangeText={readParam => setReadParam(readParam)}
454+
placeholderTextColor = "#9a73ef"
455+
autoCapitalize = "none"
456+
/>
457+
</View>
458+
<Button
459+
title="Read UTF8 file"
460+
color="#9a73ef"
461+
onPress={readFileUTF8Call}
462+
/>
463+
<Button
464+
title="Read ASCII file"
465+
color="#9a73ef"
466+
onPress={readFileASCIICall}
467+
/>
468+
<Button
469+
title="Read base64 file"
470+
color="#9a73ef"
471+
onPress={readFileBase64Call}
472+
/>
473+
</View>
474+
</View>
475+
476+
<View style={styles.body}>
477+
<View style={styles.sectionContainer}>
478+
<Text style={styles.sectionTitle}>
479+
{"Hash - hash()"}
480+
</Text>
481+
<View style={styles.sectionDescription}>
482+
<TextInput style = {styles.input}
483+
placeholder = "Source path"
484+
onChangeText={hashPathParam => setHashPathParam(hashPathParam)}
485+
placeholderTextColor = "#9a73ef"
486+
autoCapitalize = "none"
487+
/>
488+
<Picker
489+
hashAlgValue={hashAlgValue}
490+
onChangeText={readPositionParam => setReadPositionParam(readPositionParam)}
491+
style={{ height: 50, width: 150 }}
492+
onValueChange={(itemValue, itemIndex) => setHashAlgValue(itemValue)}
493+
>
494+
<Picker.Item label="MD5" value="md5" />
495+
<Picker.Item label="SHA1" value="sha1" />
496+
<Picker.Item label="SHA224" value="sha224" />
497+
<Picker.Item label="SHA256" value="sha256" />
498+
<Picker.Item label="SHA384" value="sha384" />
499+
<Picker.Item label="SHA512" value="sha512" />
500+
</Picker>
501+
</View>
502+
<Button
503+
title="Hash File"
504+
color="#9a73ef"
505+
onPress={hashCall}
506+
/>
507+
</View>
508+
</View>
266509

267510
</ScrollView>
268511
</SafeAreaView>

RNFetchBlobWin/android/app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ dependencies {
193193

194194
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
195195
exclude group:'com.facebook.flipper'
196-
exclude group:'com.squareup.okhttp3', module:'okhttp'
197196
}
198197

199198
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {

RNFetchBlobWin/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
},
1212
"dependencies": {
1313
"react": "16.13.1",
14-
"react-native": "0.63.2",
15-
"react-native-windows": "^0.63.0-0",
16-
"rn-fetch-blob": "https://github.com/avmoroz/rn-fetch-blob.git#dev"
14+
"react-native": "0.63.0",
15+
"react-native-windows": "0.63.0",
16+
"rn-fetch-blob": "^0.12.0"
1717
},
1818
"devDependencies": {
1919
"@babel/core": "^7.8.4",

RNFetchBlobWin/windows/RNFetchBlobWin.sln

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.29215.179
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RNFetchBlobWin", "RNFetchBlobWin\RNFetchBlobWin.vcxproj", "{88699F82-267F-4871-ADE6-17E8232648E3}"
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RNFetchBlobWin", "RNFetchBlobWin\RNFetchBlobWin.vcxproj", "{15B116B3-7FD7-492E-A8F0-11135D797AA4}"
77
ProjectSection(ProjectDependencies) = postProject
88
{F7D32BD0-2749-483E-9A0D-1635EF7E3136} = {F7D32BD0-2749-483E-9A0D-1635EF7E3136}
99
EndProjectSection
@@ -49,6 +49,7 @@ Global
4949
..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{da8b35b3-da00-4b02-bde6-6a397b3fd46b}*SharedItemsImports = 9
5050
..\node_modules\react-native-windows\include\Include.vcxitems*{ef074ba1-2d54-4d49-a28e-5e040b47cd2e}*SharedItemsImports = 9
5151
..\node_modules\react-native-windows\Chakra\Chakra.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
52+
..\node_modules\react-native-windows\JSI\Shared\JSI.Shared.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
5253
..\node_modules\react-native-windows\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
5354
..\node_modules\react-native-windows\Mso\Mso.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
5455
..\node_modules\react-native-windows\Shared\Shared.vcxitems*{f7d32bd0-2749-483e-9a0d-1635ef7e3136}*SharedItemsImports = 4
@@ -64,30 +65,30 @@ Global
6465
Release|x86 = Release|x86
6566
EndGlobalSection
6667
GlobalSection(ProjectConfigurationPlatforms) = postSolution
67-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|ARM.ActiveCfg = Debug|ARM
68-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|ARM.Build.0 = Debug|ARM
69-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|ARM.Deploy.0 = Debug|ARM
70-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|ARM64.ActiveCfg = Debug|ARM64
71-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|ARM64.Build.0 = Debug|ARM64
72-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|ARM64.Deploy.0 = Debug|ARM64
73-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|x64.ActiveCfg = Debug|x64
74-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|x64.Build.0 = Debug|x64
75-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|x64.Deploy.0 = Debug|x64
76-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|x86.ActiveCfg = Debug|Win32
77-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|x86.Build.0 = Debug|Win32
78-
{88699F82-267F-4871-ADE6-17E8232648E3}.Debug|x86.Deploy.0 = Debug|Win32
79-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|ARM.ActiveCfg = Release|ARM
80-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|ARM.Build.0 = Release|ARM
81-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|ARM.Deploy.0 = Release|ARM
82-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|ARM64.ActiveCfg = Release|ARM64
83-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|ARM64.Build.0 = Release|ARM64
84-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|ARM64.Deploy.0 = Release|ARM64
85-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|x64.ActiveCfg = Release|x64
86-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|x64.Build.0 = Release|x64
87-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|x64.Deploy.0 = Release|x64
88-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|x86.ActiveCfg = Release|Win32
89-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|x86.Build.0 = Release|Win32
90-
{88699F82-267F-4871-ADE6-17E8232648E3}.Release|x86.Deploy.0 = Release|Win32
68+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|ARM.ActiveCfg = Debug|ARM
69+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|ARM.Build.0 = Debug|ARM
70+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|ARM.Deploy.0 = Debug|ARM
71+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|ARM64.ActiveCfg = Debug|ARM64
72+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|ARM64.Build.0 = Debug|ARM64
73+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|ARM64.Deploy.0 = Debug|ARM64
74+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|x64.ActiveCfg = Debug|x64
75+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|x64.Build.0 = Debug|x64
76+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|x64.Deploy.0 = Debug|x64
77+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|x86.ActiveCfg = Debug|Win32
78+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|x86.Build.0 = Debug|Win32
79+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Debug|x86.Deploy.0 = Debug|Win32
80+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|ARM.ActiveCfg = Release|ARM
81+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|ARM.Build.0 = Release|ARM
82+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|ARM.Deploy.0 = Release|ARM
83+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|ARM64.ActiveCfg = Release|ARM64
84+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|ARM64.Build.0 = Release|ARM64
85+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|ARM64.Deploy.0 = Release|ARM64
86+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|x64.ActiveCfg = Release|x64
87+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|x64.Build.0 = Release|x64
88+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|x64.Deploy.0 = Release|x64
89+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|x86.ActiveCfg = Release|Win32
90+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|x86.Build.0 = Release|Win32
91+
{15B116B3-7FD7-492E-A8F0-11135D797AA4}.Release|x86.Deploy.0 = Release|Win32
9192
{A990658C-CE31-4BCC-976F-0FC6B1AF693D}.Debug|ARM.ActiveCfg = Debug|ARM
9293
{A990658C-CE31-4BCC-976F-0FC6B1AF693D}.Debug|ARM.Build.0 = Debug|ARM
9394
{A990658C-CE31-4BCC-976F-0FC6B1AF693D}.Debug|ARM64.ActiveCfg = Debug|ARM64

RNFetchBlobWin/windows/RNFetchBlobWin/Package.appxmanifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
IgnorableNamespaces="uap mp">
88

99
<Identity
10-
Name="f0f97f86-7678-420a-9b96-dfbedb29142c"
10+
Name="cf7fc71c-3c45-4933-b6e1-d925ae04770b"
1111
Publisher="CN=andre"
1212
Version="1.0.0.0" />
1313

14-
<mp:PhoneIdentity PhoneProductId="f0f97f86-7678-420a-9b96-dfbedb29142c" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
14+
<mp:PhoneIdentity PhoneProductId="cf7fc71c-3c45-4933-b6e1-d925ae04770b" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
1515

1616
<Properties>
1717
<DisplayName>RNFetchBlobWin</DisplayName>

0 commit comments

Comments
 (0)