Skip to content

Commit 43941d7

Browse files
committed
Merge branch 'user/anuverma/windows' of https://github.com/anupriya13/react-native-blob-util into user/anuverma/windows
2 parents 4258d69 + ba9052d commit 43941d7

File tree

7 files changed

+563
-2538
lines changed

7 files changed

+563
-2538
lines changed

android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilFileResp.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,19 @@ public MediaType contentType() {
7272

7373
@Override
7474
public long contentLength() {
75-
if (originalBody.contentLength() > Integer.MAX_VALUE) {
75+
76+
/**
77+
*
78+
* Okio buffer issue in current version seems to be fixed in the latest versions
79+
*
80+
* limiting this was causing the download progress to stop at 2GB size but files still was downloading
81+
*
82+
*/
83+
84+
// if (originalBody.contentLength() > Integer.MAX_VALUE) {
7685
// This is a workaround for a bug Okio buffer where it can't handle larger than int.
77-
return Integer.MAX_VALUE;
78-
}
86+
// return Integer.MAX_VALUE;
87+
// }
7988
return originalBody.contentLength();
8089
}
8190

examples/ReactNativeBlobUtil/App.js

Lines changed: 106 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import React, {useState} from 'react';
10-
import {Alert, Button, SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, TextInput, View} from 'react-native';
10+
import {Alert, Button, ScrollView, StyleSheet, Text, TextInput, View} from 'react-native';
1111
// import {Picker} from '@react-native-picker/picker'; Need to remove this package as it is not supported in Windows New Architecture
1212

1313
import {Colors} from 'react-native/Libraries/NewAppScreen';
@@ -489,8 +489,7 @@ const App: () => React$Node = () => {
489489
// App ************************************************************************
490490
return (
491491
<>
492-
<StatusBar barStyle="dark-content" />
493-
<SafeAreaView>
492+
<View>
494493
<ScrollView contentInsetAdjustmentBehavior="automatic" style={styles.scrollView}>
495494
{global.HermesInternal == null ? null : (
496495
<View style={styles.engine}>
@@ -604,46 +603,116 @@ const App: () => React$Node = () => {
604603
</View>
605604

606605
<View style={styles.body}>
607-
<View style={styles.sectionContainer}>
608-
<Text style={styles.sectionTitle}>{'Hash - hash()'}</Text>
609-
<View style={styles.sectionDescription}>
610-
<TextInput style={styles.input} placeholder="Source path" onChangeText={(hashPathParam) => setHashPathParam(hashPathParam)} placeholderTextColor="#9a73ef" autoCapitalize="none" />
611-
</View>
612-
<Button title="Hash File" color="#9a73ef" onPress={hashCall} />
606+
<View style={styles.sectionContainer}>
607+
<Text style={styles.sectionTitle}>{'Hash - hash()'}</Text>
608+
<View style={styles.sectionDescription}>
609+
<TextInput
610+
style={styles.input}
611+
placeholder="Source path"
612+
onChangeText={setHashPathParam}
613+
placeholderTextColor="#9a73ef"
614+
autoCapitalize="none"
615+
/>
616+
<View style={styles.buttonGroup}>
617+
{['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'].map((alg) => (
618+
<Button
619+
key={alg}
620+
title={alg.toUpperCase()}
621+
color={hashAlgValue === alg ? '#7a42f4' : '#ccc'}
622+
onPress={() => setHashAlgValue(alg)}
623+
/>
624+
))}
613625
</View>
626+
</View>
627+
<Button title="Hash File" color="#9a73ef" onPress={hashCall} />
628+
</View>
614629
</View>
615630

616631
<View style={styles.body}>
617-
<View style={styles.sectionContainer}>
618-
<Text style={styles.sectionTitle}>{'write - writeFile(), appendFile()'}</Text>
619-
<View style={styles.sectionDescription}>
620-
<TextInput style={styles.input} placeholder="Source path" onChangeText={(writeParam) => setWriteParam(writeParam)} placeholderTextColor="#9a73ef" autoCapitalize="none" />
621-
<TextInput style={styles.input} placeholder="Source path" onChangeText={(writeURIParam) => setWriteURIParam(writeURIParam)} placeholderTextColor="#9a73ef" autoCapitalize="none" />
622-
</View>
623-
<Button title="Write" color="#9a73ef" onPress={writeFileCall} />
624-
<Button title="Append" color="#9a73ef" onPress={appendFileCall} />
632+
<View style={styles.sectionContainer}>
633+
<Text style={styles.sectionTitle}>{'write - writeFile(), appendFile()'}</Text>
634+
<View style={styles.sectionDescription}>
635+
<TextInput
636+
style={styles.input}
637+
placeholder="Source path"
638+
onChangeText={setWriteParam}
639+
placeholderTextColor="#9a73ef"
640+
autoCapitalize="none"
641+
/>
642+
<TextInput
643+
style={styles.input}
644+
placeholder="Destination path"
645+
onChangeText={setWriteURIParam}
646+
placeholderTextColor="#9a73ef"
647+
autoCapitalize="none"
648+
/>
649+
<View style={styles.buttonGroup}>
650+
{['utf8', 'base64', 'ascii', 'uri'].map((enc) => (
651+
<Button
652+
key={enc}
653+
title={enc.toUpperCase()}
654+
color={writeEncodeParam === enc ? '#7a42f4' : '#ccc'}
655+
onPress={() => setWriteEncodeParam(enc)}
656+
/>
657+
))}
625658
</View>
659+
</View>
660+
<Button title="Write" color="#9a73ef" onPress={writeFileCall} />
661+
<Button title="Append" color="#9a73ef" onPress={appendFileCall} />
662+
</View>
626663
</View>
627664

628665
<View style={styles.body}>
629-
<View style={styles.sectionContainer}>
630-
<Text style={styles.sectionTitle}>{'WriteStream - writeStream()'}</Text>
631-
<View style={styles.sectionDescription}>
632-
<TextInput style={styles.input} placeholder="Source path" onChangeText={(writeStreamParam) => setWriteStreamParam(writeStreamParam)} placeholderTextColor="#9a73ef" autoCapitalize="none" />
633-
</View>
634-
<Button title="Write" color="#9a73ef" onPress={writeStreamCall} />
635-
<Button title="Append" color="#9a73ef" onPress={appendStreamCall} />
666+
<View style={styles.sectionContainer}>
667+
<Text style={styles.sectionTitle}>{'WriteStream - writeStream()'}</Text>
668+
<View style={styles.sectionDescription}>
669+
<TextInput
670+
style={styles.input}
671+
placeholder="Source path"
672+
onChangeText={setWriteStreamParam}
673+
placeholderTextColor="#9a73ef"
674+
autoCapitalize="none"
675+
/>
676+
<View style={styles.buttonGroup}>
677+
{['utf8', 'base64', 'ascii'].map((enc) => (
678+
<Button
679+
key={enc}
680+
title={enc.toUpperCase()}
681+
color={writeEncodeStreamParam === enc ? '#7a42f4' : '#ccc'}
682+
onPress={() => setWriteStreamEncodeParam(enc)}
683+
/>
684+
))}
636685
</View>
686+
</View>
687+
<Button title="Write" color="#9a73ef" onPress={writeStreamCall} />
688+
<Button title="Append" color="#9a73ef" onPress={appendStreamCall} />
689+
</View>
637690
</View>
638691

639692
<View style={styles.body}>
640-
<View style={styles.sectionContainer}>
641-
<Text style={styles.sectionTitle}>{'ReadStream - readStream()'}</Text>
642-
<View style={styles.sectionDescription}>
643-
<TextInput style={styles.input} placeholder="Source path" onChangeText={(readStreamParam) => setReadStreamParam(readStreamParam)} placeholderTextColor="#9a73ef" autoCapitalize="none" />
644-
</View>
645-
<Button title="Read" color="#9a73ef" onPress={readStreamCall} />
693+
<View style={styles.sectionContainer}>
694+
<Text style={styles.sectionTitle}>{'ReadStream - readStream()'}</Text>
695+
<View style={styles.sectionDescription}>
696+
<TextInput
697+
style={styles.input}
698+
placeholder="Source path"
699+
onChangeText={setReadStreamParam}
700+
placeholderTextColor="#9a73ef"
701+
autoCapitalize="none"
702+
/>
703+
<View style={styles.buttonGroup}>
704+
{['utf8', 'base64', 'ascii'].map((enc) => (
705+
<Button
706+
key={enc}
707+
title={enc.toUpperCase()}
708+
color={readEncodeStreamParam === enc ? '#7a42f4' : '#ccc'}
709+
onPress={() => setReadStreamEncodeParam(enc)}
710+
/>
711+
))}
646712
</View>
713+
</View>
714+
<Button title="Read" color="#9a73ef" onPress={readStreamCall} />
715+
</View>
647716
</View>
648717

649718
<View style={styles.body}>
@@ -659,7 +728,7 @@ const App: () => React$Node = () => {
659728
</View>
660729
</View>
661730
</ScrollView>
662-
</SafeAreaView>
731+
</View>
663732
</>
664733
);
665734
};
@@ -701,6 +770,12 @@ const styles = StyleSheet.create({
701770
paddingRight: 12,
702771
textAlign: 'right',
703772
},
773+
buttonGroup: {
774+
flexDirection: 'row',
775+
flexWrap: 'wrap',
776+
gap: 8,
777+
marginVertical: 8,
778+
},
704779
});
705780

706781
export default App;

examples/ReactNativeBlobUtil/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "react-native start",
99
"test": "jest",
1010
"lint": "eslint .",
11-
"windows": "npx @react-native-community/cli run-windows",
11+
"windows": "npx @react-native-community/cli run-windows --release",
1212
"test:windows": "jest --config jest.config.windows.js"
1313
},
1414
"dependencies": {
@@ -21,10 +21,10 @@
2121
"@babel/core": "^7.12.9",
2222
"@babel/runtime": "^7.12.5",
2323
"@react-native-community/eslint-config": "^2.0.0",
24-
"babel-jest": "^26.6.3",
24+
"babel-jest": "^29.0.0",
2525
"eslint": "^7.32.0",
26-
"jest": "^26.6.3",
27-
"metro-react-native-babel-preset": "0.72.3",
26+
"jest": "^29.0.0",
27+
"@react-native/babel-preset": "^0.76.0",
2828
"react-test-renderer": "18.1.0",
2929
"@rnx-kit/jest-preset": "^0.1.17",
3030
"@react-native/metro-config": "^0.76.9",

0 commit comments

Comments
 (0)