react-native-my-uploader-android 1.0.24 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -176
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,192 +1,62 @@
|
|
|
1
1
|
# react-native-my-uploader
|
|
2
2
|
|
|
3
|
-
file uploader
|
|
3
|
+
file uploader for android
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
npm install react-native-my-uploader
|
|
9
|
+
npm install react-native-my-uploader-android
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
## Usage
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
```js
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<View style={styles.container}>
|
|
66
|
-
<StatusBar barStyle="dark-content" />
|
|
67
|
-
<View style={styles.header}>
|
|
68
|
-
<Text style={styles.title}>Dosya Yükleyici Paket Testi</Text>
|
|
69
|
-
</View>
|
|
70
|
-
|
|
71
|
-
<View style={styles.buttonGrid}>
|
|
72
|
-
<Button
|
|
73
|
-
title="Tek Bir Görüntü Seç"
|
|
74
|
-
onPress={() =>
|
|
75
|
-
handlePickFile({
|
|
76
|
-
multipleFiles: false,
|
|
77
|
-
fileTypes: ['image/*'],
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
/>
|
|
81
|
-
<Button
|
|
82
|
-
title="birden Fazla Dosya Seç (Maks 2MB)"
|
|
83
|
-
onPress={() =>
|
|
84
|
-
handlePickFile({
|
|
85
|
-
multipleFiles: true,
|
|
86
|
-
fileTypes: ['application/*'],
|
|
87
|
-
maxSize: 2,
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
/>
|
|
91
|
-
<Button
|
|
92
|
-
title="Listeyi Temizle"
|
|
93
|
-
color="#c0392b"
|
|
94
|
-
onPress={() => setSelectedFiles([])}
|
|
95
|
-
/>
|
|
96
|
-
</View>
|
|
97
|
-
|
|
98
|
-
<View style={styles.resultsArea}>
|
|
99
|
-
<Text style={styles.resultsTitle}>
|
|
100
|
-
Seçilen Dosyalar ({selectedFiles.length} adet)
|
|
101
|
-
</Text>
|
|
102
|
-
<ScrollView contentContainerStyle={styles.scrollViewContent}>
|
|
103
|
-
{selectedFiles.length > 0 ? (
|
|
104
|
-
selectedFiles.map((file, index) => (
|
|
105
|
-
<View key={`${file.fileUri}-${index}`} style={styles.fileCard}>
|
|
106
|
-
<Text style={styles.fileName} numberOfLines={1}>
|
|
107
|
-
{file.fileName}
|
|
108
|
-
</Text>
|
|
109
|
-
<Text style={styles.fileDetail}>
|
|
110
|
-
Boyut: {(file.fileSize / 1024).toFixed(2)} KB
|
|
111
|
-
</Text>
|
|
112
|
-
</View>
|
|
113
|
-
))
|
|
114
|
-
) : (
|
|
115
|
-
<Text style={styles.noFilesText}>
|
|
116
|
-
Seçilen dosya yok.
|
|
117
|
-
</Text>
|
|
118
|
-
)}
|
|
119
|
-
</ScrollView>
|
|
120
|
-
</View>
|
|
121
|
-
</View>
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const styles = StyleSheet.create({
|
|
126
|
-
container: {
|
|
127
|
-
flex: 1,
|
|
128
|
-
backgroundColor: '#f0f2f5',
|
|
129
|
-
},
|
|
130
|
-
header: {
|
|
131
|
-
padding: 20,
|
|
132
|
-
alignItems: 'center',
|
|
133
|
-
},
|
|
134
|
-
title: {
|
|
135
|
-
fontSize: 22,
|
|
136
|
-
fontWeight: 'bold',
|
|
137
|
-
color: '#1c1e21',
|
|
138
|
-
},
|
|
139
|
-
buttonGrid: {
|
|
140
|
-
paddingHorizontal: 20,
|
|
141
|
-
gap: 10,
|
|
142
|
-
},
|
|
143
|
-
resultsArea: {
|
|
144
|
-
flex: 1,
|
|
145
|
-
marginTop: 20,
|
|
146
|
-
borderTopWidth: 1,
|
|
147
|
-
borderTopColor: '#dddfe2',
|
|
148
|
-
paddingHorizontal: 20,
|
|
149
|
-
},
|
|
150
|
-
resultsTitle: {
|
|
151
|
-
fontSize: 18,
|
|
152
|
-
fontWeight: '600',
|
|
153
|
-
paddingVertical: 15,
|
|
154
|
-
color: '#1c1e21',
|
|
155
|
-
},
|
|
156
|
-
scrollViewContent: {
|
|
157
|
-
paddingBottom: 20,
|
|
158
|
-
},
|
|
159
|
-
fileCard: {
|
|
160
|
-
backgroundColor: '#ffffff',
|
|
161
|
-
padding: 15,
|
|
162
|
-
borderRadius: 8,
|
|
163
|
-
marginBottom: 10,
|
|
164
|
-
shadowColor: '#000',
|
|
165
|
-
shadowOffset: {width: 0, height: 1},
|
|
166
|
-
shadowOpacity: 0.2,
|
|
167
|
-
shadowRadius: 1.41,
|
|
168
|
-
elevation: 2,
|
|
169
|
-
},
|
|
170
|
-
fileName: {
|
|
171
|
-
fontSize: 16,
|
|
172
|
-
fontWeight: 'bold',
|
|
173
|
-
color: '#000',
|
|
174
|
-
},
|
|
175
|
-
fileDetail: {
|
|
176
|
-
fontSize: 13,
|
|
177
|
-
color: '#555',
|
|
178
|
-
marginTop: 4,
|
|
179
|
-
},
|
|
180
|
-
noFilesText: {
|
|
181
|
-
textAlign: 'center',
|
|
182
|
-
color: '#888',
|
|
183
|
-
marginTop: 30,
|
|
184
|
-
fontStyle: 'italic',
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
export default App;
|
|
16
|
+
import MyUploader,{FileInfo} from 'react-native-my-uploader-android';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const [selectedFiles, setSelectedFiles] = useState<FileInfo[]>([]); // response= base64,fileName,fileSize,fileType,FileUri
|
|
20
|
+
|
|
21
|
+
Usage
|
|
22
|
+
<MyUploader
|
|
23
|
+
multipleFiles={false}
|
|
24
|
+
// maxFiles={3}
|
|
25
|
+
maxSize={5} // 5MB
|
|
26
|
+
fileTypes={["*/*"]}
|
|
27
|
+
buttonPlaceHolder="Dosya Seç (En Fazla 3)"
|
|
28
|
+
ButtonStyle={styles.customButton}
|
|
29
|
+
ButtonTextStyle={styles.customButtonText}
|
|
30
|
+
onSelect={(files) => {
|
|
31
|
+
console.log('Dosyalar seçildi:', files);
|
|
32
|
+
// Yeni seçilenleri mevcut listeye ekle
|
|
33
|
+
setSelectedFiles(prevFiles => [...prevFiles, ...files]);
|
|
34
|
+
}}
|
|
35
|
+
onError={(error) => {
|
|
36
|
+
Alert.alert(`Bir hata oluştu: ${error.message}`);
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
or
|
|
41
|
+
|
|
42
|
+
<MyUploader
|
|
43
|
+
multipleFiles={true}
|
|
44
|
+
maxFiles={3}
|
|
45
|
+
maxSize={5} // 5MB
|
|
46
|
+
fileTypes={['application/pdf', 'image/jpeg']}
|
|
47
|
+
buttonPlaceHolder="Dosya Seç (En Fazla 3)"
|
|
48
|
+
ButtonStyle={styles.customButton}
|
|
49
|
+
ButtonTextStyle={styles.customButtonText}
|
|
50
|
+
onSelect={(files) => {
|
|
51
|
+
console.log('Dosyalar seçildi:', files);
|
|
52
|
+
// Yeni seçilenleri mevcut listeye ekle
|
|
53
|
+
setSelectedFiles(prevFiles => [...prevFiles, ...files]);
|
|
54
|
+
}}
|
|
55
|
+
onError={(error) => {
|
|
56
|
+
Alert.alert(`Bir hata oluştu: ${error.message}`);
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
|
|
190
60
|
```
|
|
191
61
|
|
|
192
62
|
|