react-native-my-uploader-android 1.0.43 → 1.0.44
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/android/src/main/java/com/myuploaderandroid/MyUploaderModule.kt +11 -4
- package/lib/commonjs/components/MyUploader.js +3 -2
- package/lib/commonjs/components/MyUploader.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/components/MyUploader.js +3 -2
- package/lib/module/components/MyUploader.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MyUploader.tsx +1 -0
- package/src/types.ts +1 -0
|
@@ -22,6 +22,7 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
22
22
|
private var maxSize: Double = 0.0
|
|
23
23
|
private var maxFiles: Int = 0
|
|
24
24
|
private var excludedUris: List<String> = emptyList()
|
|
25
|
+
private var withBase64: Boolean = true
|
|
25
26
|
|
|
26
27
|
init {
|
|
27
28
|
reactContext.addActivityEventListener(this)
|
|
@@ -67,8 +68,8 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
67
68
|
// Değerleri sınıf değişkenlerine ata
|
|
68
69
|
this.maxFiles = effectiveMaxFiles
|
|
69
70
|
this.maxSize = options.takeIf { it.hasKey("maxSize") }?.getDouble("maxSize") ?: 0.0
|
|
70
|
-
this.excludedUris = options.takeIf { it.hasKey("excludedUris") }
|
|
71
|
-
|
|
71
|
+
this.excludedUris = options.takeIf { it.hasKey("excludedUris") }?.getArray("excludedUris")?.toArrayList()?.mapNotNull { it.toString() } ?: emptyList()
|
|
72
|
+
this.withBase64 = options.takeIf { it.hasKey("withBase64") }?.getBoolean("withBase64") ?: true
|
|
72
73
|
|
|
73
74
|
val currentActivity = reactContext.currentActivity
|
|
74
75
|
if (currentActivity == null) {
|
|
@@ -378,14 +379,20 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
378
379
|
}
|
|
379
380
|
|
|
380
381
|
val mimeType = reactContext.contentResolver.getType(uri) ?: URLConnection.guessContentTypeFromName(fileName) ?: "application/octet-stream"
|
|
381
|
-
val base64 =
|
|
382
|
+
val base64 = if (this.withBase64) {
|
|
383
|
+
encodeFileToBase64(uri)
|
|
384
|
+
} else {
|
|
385
|
+
null
|
|
386
|
+
}
|
|
382
387
|
|
|
383
388
|
val fileMap = WritableNativeMap().apply {
|
|
384
389
|
putString("fileName", fileName)
|
|
385
390
|
putDouble("fileSize", if (trueSize > 0) trueSize.toDouble() else fileSize.toDouble())
|
|
386
391
|
putString("fileType", mimeType)
|
|
387
392
|
putString("fileUri", uri.toString())
|
|
388
|
-
|
|
393
|
+
if (withBase64 && base64 != null) {
|
|
394
|
+
putString("base64", base64)
|
|
395
|
+
}
|
|
389
396
|
}
|
|
390
397
|
fileObjects.pushMap(fileMap)
|
|
391
398
|
}
|
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
|
|
14
14
|
// 1. Standalone pickFile Fonksiyonu
|
|
15
15
|
const pickFile = async (options = {}) => {
|
|
16
|
-
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris, _options$isGallery;
|
|
16
|
+
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris, _options$isGallery, _options$withBase;
|
|
17
17
|
if (!NativeUploadPicker) throw new Error("DocumentPicker module is not linked.");
|
|
18
18
|
|
|
19
19
|
// Native tarafa gönderilecek options
|
|
@@ -23,7 +23,8 @@ const pickFile = async (options = {}) => {
|
|
|
23
23
|
maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0,
|
|
24
24
|
fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
|
|
25
25
|
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
|
|
26
|
-
isGallery: (_options$isGallery = options.isGallery) !== null && _options$isGallery !== void 0 ? _options$isGallery : false
|
|
26
|
+
isGallery: (_options$isGallery = options.isGallery) !== null && _options$isGallery !== void 0 ? _options$isGallery : false,
|
|
27
|
+
withBase64: (_options$withBase = options.withBase64) !== null && _options$withBase !== void 0 ? _options$withBase : true
|
|
27
28
|
};
|
|
28
29
|
return await NativeUploadPicker.openDocument(nativeOptions);
|
|
29
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","UploadDocumentPicker","NativeUploadPicker","NativeModules","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","_options$isGallery","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","isGallery","openDocument","exports","getBase64FromUri","cropFileUri","error","message","CropImageWithBase64","base64","cropData","RotateImage","angle","rotatedBase64","rotateImage","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","useState","handlePress","files","console","createElement","TouchableOpacity","style","styles","button","onPress","ActivityIndicator","color","Text","text","StyleSheet","create","backgroundColor","padding","borderRadius","alignItems","justifyContent","fontWeight","fontSize","_default"],"sources":["MyUploader.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';\r\nimport type { MyUploaderProps, DocumentPickerOptions, FileInfo, RotateImageProps } from '../types';\r\n\r\nconst { UploadDocumentPicker: NativeUploadPicker } = NativeModules;\r\n\r\n// 1. Standalone pickFile Fonksiyonu\r\nexport const pickFile = async (options: DocumentPickerOptions = {}): Promise<FileInfo[]> => {\r\n if (!NativeUploadPicker) throw new Error(\"DocumentPicker module is not linked.\");\r\n\r\n // Native tarafa gönderilecek options\r\n const nativeOptions = {\r\n multipleFiles: options.multipleFiles ?? false,\r\n maxFiles: options.maxFiles ?? 0,\r\n maxSize: options.maxSize ?? 0,\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n excludedUris: options.excludedUris ?? [],\r\n isGallery:options.isGallery ?? false,\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\nexport const getBase64FromUri = async (cropFileUri: string): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.getBase64FromUri(cropFileUri);\r\n } catch (error: any) {\r\n throw new Error(`getBase64FromUri Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n\r\nexport const CropImageWithBase64 = async (base64: string,cropData:any): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.CropImageWithBase64(base64,cropData);\r\n } catch (error: any) {\r\n throw new Error(`CropImageWithBase64 Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n \r\n\r\nexport const RotateImage = async ({ base64, angle }: RotateImageProps): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n // Native sadece saf base64 string'i döner\r\n const rotatedBase64: string = await NativeUploadPicker.rotateImage(base64, angle);\r\n\r\n // Uygulama tarafında doğrudan <Image /> içinde kullanılabilmesi için prefix eklenir\r\n return `data:image/jpeg;base64,${rotatedBase64}`;\r\n } catch (error: any) {\r\n // Hata mesajını daha okunaklı fırlatıyoruz\r\n throw new Error(`RotateImage Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n// 2. MyUploader Bileşeni\r\nconst MyUploader: React.FC<MyUploaderProps> = ({\r\n onSelect,\r\n onError,\r\n buttonPlaceHolder = \"Dosya Seç\",\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n multipleFiles = false,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n maxFiles = 0,\r\n excludedUris = [],\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading) return;\r\n setIsLoading(true);\r\n\r\n try {\r\n const files = await pickFile({\r\n multipleFiles,\r\n fileTypes,\r\n maxSize,\r\n maxFiles,\r\n excludedUris\r\n });\r\n\r\n onSelect(files);\r\n } catch (error: any) {\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error(\"MyUploader Error:\", error);\r\n }\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n <Text style={[styles.text, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#6200EE',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center'\r\n },\r\n text: {\r\n color: '#FFF',\r\n fontWeight: '600',\r\n fontSize: 16\r\n },\r\n disabled: {\r\n backgroundColor: '#B0B0B0'\r\n }\r\n});\r\n\r\nexport default MyUploader;"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAoG,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA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A,CAAA7B,OAAA,GAEYyC,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","UploadDocumentPicker","NativeUploadPicker","NativeModules","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","_options$isGallery","_options$withBase","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","isGallery","withBase64","openDocument","exports","getBase64FromUri","cropFileUri","error","message","CropImageWithBase64","base64","cropData","RotateImage","angle","rotatedBase64","rotateImage","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","useState","handlePress","files","console","createElement","TouchableOpacity","style","styles","button","onPress","ActivityIndicator","color","Text","text","StyleSheet","create","backgroundColor","padding","borderRadius","alignItems","justifyContent","fontWeight","fontSize","_default"],"sources":["MyUploader.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';\r\nimport type { MyUploaderProps, DocumentPickerOptions, FileInfo, RotateImageProps } from '../types';\r\n\r\nconst { UploadDocumentPicker: NativeUploadPicker } = NativeModules;\r\n\r\n// 1. Standalone pickFile Fonksiyonu\r\nexport const pickFile = async (options: DocumentPickerOptions = {}): Promise<FileInfo[]> => {\r\n if (!NativeUploadPicker) throw new Error(\"DocumentPicker module is not linked.\");\r\n\r\n // Native tarafa gönderilecek options\r\n const nativeOptions = {\r\n multipleFiles: options.multipleFiles ?? false,\r\n maxFiles: options.maxFiles ?? 0,\r\n maxSize: options.maxSize ?? 0,\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n excludedUris: options.excludedUris ?? [],\r\n isGallery:options.isGallery ?? false,\r\n withBase64:options.withBase64 ?? true,\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\nexport const getBase64FromUri = async (cropFileUri: string): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.getBase64FromUri(cropFileUri);\r\n } catch (error: any) {\r\n throw new Error(`getBase64FromUri Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n\r\nexport const CropImageWithBase64 = async (base64: string,cropData:any): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.CropImageWithBase64(base64,cropData);\r\n } catch (error: any) {\r\n throw new Error(`CropImageWithBase64 Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n \r\n\r\nexport const RotateImage = async ({ base64, angle }: RotateImageProps): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n // Native sadece saf base64 string'i döner\r\n const rotatedBase64: string = await NativeUploadPicker.rotateImage(base64, angle);\r\n\r\n // Uygulama tarafında doğrudan <Image /> içinde kullanılabilmesi için prefix eklenir\r\n return `data:image/jpeg;base64,${rotatedBase64}`;\r\n } catch (error: any) {\r\n // Hata mesajını daha okunaklı fırlatıyoruz\r\n throw new Error(`RotateImage Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n// 2. MyUploader Bileşeni\r\nconst MyUploader: React.FC<MyUploaderProps> = ({\r\n onSelect,\r\n onError,\r\n buttonPlaceHolder = \"Dosya Seç\",\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n multipleFiles = false,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n maxFiles = 0,\r\n excludedUris = [],\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading) return;\r\n setIsLoading(true);\r\n\r\n try {\r\n const files = await pickFile({\r\n multipleFiles,\r\n fileTypes,\r\n maxSize,\r\n maxFiles,\r\n excludedUris\r\n });\r\n\r\n onSelect(files);\r\n } catch (error: any) {\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error(\"MyUploader Error:\", error);\r\n }\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n <Text style={[styles.text, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#6200EE',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center'\r\n },\r\n text: {\r\n color: '#FFF',\r\n fontWeight: '600',\r\n fontSize: 16\r\n },\r\n disabled: {\r\n backgroundColor: '#B0B0B0'\r\n }\r\n});\r\n\r\nexport default MyUploader;"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAoG,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAA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
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n isGallery?:boolean;\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n isGallery?:boolean;\r\n withBase64?:boolean;\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
|
|
7
7
|
// 1. Standalone pickFile Fonksiyonu
|
|
8
8
|
export const pickFile = async (options = {}) => {
|
|
9
|
-
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris, _options$isGallery;
|
|
9
|
+
var _options$multipleFile, _options$maxFiles, _options$maxSize, _options$fileTypes, _options$excludedUris, _options$isGallery, _options$withBase;
|
|
10
10
|
if (!NativeUploadPicker) throw new Error("DocumentPicker module is not linked.");
|
|
11
11
|
|
|
12
12
|
// Native tarafa gönderilecek options
|
|
@@ -16,7 +16,8 @@ export const pickFile = async (options = {}) => {
|
|
|
16
16
|
maxSize: (_options$maxSize = options.maxSize) !== null && _options$maxSize !== void 0 ? _options$maxSize : 0,
|
|
17
17
|
fileTypes: (_options$fileTypes = options.fileTypes) !== null && _options$fileTypes !== void 0 ? _options$fileTypes : ['*/*'],
|
|
18
18
|
excludedUris: (_options$excludedUris = options.excludedUris) !== null && _options$excludedUris !== void 0 ? _options$excludedUris : [],
|
|
19
|
-
isGallery: (_options$isGallery = options.isGallery) !== null && _options$isGallery !== void 0 ? _options$isGallery : false
|
|
19
|
+
isGallery: (_options$isGallery = options.isGallery) !== null && _options$isGallery !== void 0 ? _options$isGallery : false,
|
|
20
|
+
withBase64: (_options$withBase = options.withBase64) !== null && _options$withBase !== void 0 ? _options$withBase : true
|
|
20
21
|
};
|
|
21
22
|
return await NativeUploadPicker.openDocument(nativeOptions);
|
|
22
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","UploadDocumentPicker","NativeUploadPicker","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","_options$isGallery","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","isGallery","openDocument","getBase64FromUri","cropFileUri","error","message","CropImageWithBase64","base64","cropData","RotateImage","angle","rotatedBase64","rotateImage","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","handlePress","files","console","createElement","style","styles","button","onPress","color","text","create","backgroundColor","padding","borderRadius","alignItems","justifyContent","fontWeight","fontSize"],"sources":["MyUploader.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';\r\nimport type { MyUploaderProps, DocumentPickerOptions, FileInfo, RotateImageProps } from '../types';\r\n\r\nconst { UploadDocumentPicker: NativeUploadPicker } = NativeModules;\r\n\r\n// 1. Standalone pickFile Fonksiyonu\r\nexport const pickFile = async (options: DocumentPickerOptions = {}): Promise<FileInfo[]> => {\r\n if (!NativeUploadPicker) throw new Error(\"DocumentPicker module is not linked.\");\r\n\r\n // Native tarafa gönderilecek options\r\n const nativeOptions = {\r\n multipleFiles: options.multipleFiles ?? false,\r\n maxFiles: options.maxFiles ?? 0,\r\n maxSize: options.maxSize ?? 0,\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n excludedUris: options.excludedUris ?? [],\r\n isGallery:options.isGallery ?? false,\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\nexport const getBase64FromUri = async (cropFileUri: string): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.getBase64FromUri(cropFileUri);\r\n } catch (error: any) {\r\n throw new Error(`getBase64FromUri Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n\r\nexport const CropImageWithBase64 = async (base64: string,cropData:any): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.CropImageWithBase64(base64,cropData);\r\n } catch (error: any) {\r\n throw new Error(`CropImageWithBase64 Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n \r\n\r\nexport const RotateImage = async ({ base64, angle }: RotateImageProps): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n // Native sadece saf base64 string'i döner\r\n const rotatedBase64: string = await NativeUploadPicker.rotateImage(base64, angle);\r\n\r\n // Uygulama tarafında doğrudan <Image /> içinde kullanılabilmesi için prefix eklenir\r\n return `data:image/jpeg;base64,${rotatedBase64}`;\r\n } catch (error: any) {\r\n // Hata mesajını daha okunaklı fırlatıyoruz\r\n throw new Error(`RotateImage Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n// 2. MyUploader Bileşeni\r\nconst MyUploader: React.FC<MyUploaderProps> = ({\r\n onSelect,\r\n onError,\r\n buttonPlaceHolder = \"Dosya Seç\",\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n multipleFiles = false,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n maxFiles = 0,\r\n excludedUris = [],\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading) return;\r\n setIsLoading(true);\r\n\r\n try {\r\n const files = await pickFile({\r\n multipleFiles,\r\n fileTypes,\r\n maxSize,\r\n maxFiles,\r\n excludedUris\r\n });\r\n\r\n onSelect(files);\r\n } catch (error: any) {\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error(\"MyUploader Error:\", error);\r\n }\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n <Text style={[styles.text, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#6200EE',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center'\r\n },\r\n text: {\r\n color: '#FFF',\r\n fontWeight: '600',\r\n fontSize: 16\r\n },\r\n disabled: {\r\n backgroundColor: '#B0B0B0'\r\n }\r\n});\r\n\r\nexport default MyUploader;"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,gBAAgB,EAAEC,IAAI,EAAEC,UAAU,EAAEC,iBAAiB,EAAEC,aAAa,QAAQ,cAAc;AAGnG,MAAM;EAAEC,oBAAoB,EAAEC;AAAmB,CAAC,GAAGF,aAAa;;AAElE;AACA,OAAO,MAAMG,QAAQ,GAAG,MAAAA,CAAOC,OAA8B,GAAG,CAAC,CAAC,KAA0B;EAAA,IAAAC,qBAAA,EAAAC,iBAAA,EAAAC,gBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA;EAC1F,IAAI,
|
|
1
|
+
{"version":3,"names":["React","useState","TouchableOpacity","Text","StyleSheet","ActivityIndicator","NativeModules","UploadDocumentPicker","NativeUploadPicker","pickFile","options","_options$multipleFile","_options$maxFiles","_options$maxSize","_options$fileTypes","_options$excludedUris","_options$isGallery","_options$withBase","Error","nativeOptions","multipleFiles","maxFiles","maxSize","fileTypes","excludedUris","isGallery","withBase64","openDocument","getBase64FromUri","cropFileUri","error","message","CropImageWithBase64","base64","cropData","RotateImage","angle","rotatedBase64","rotateImage","MyUploader","onSelect","onError","buttonPlaceHolder","ButtonStyle","ButtonTextStyle","disabled","isLoading","setIsLoading","handlePress","files","console","createElement","style","styles","button","onPress","color","text","create","backgroundColor","padding","borderRadius","alignItems","justifyContent","fontWeight","fontSize"],"sources":["MyUploader.tsx"],"sourcesContent":["import React, { useState } from 'react';\r\nimport { TouchableOpacity, Text, StyleSheet, ActivityIndicator, NativeModules } from 'react-native';\r\nimport type { MyUploaderProps, DocumentPickerOptions, FileInfo, RotateImageProps } from '../types';\r\n\r\nconst { UploadDocumentPicker: NativeUploadPicker } = NativeModules;\r\n\r\n// 1. Standalone pickFile Fonksiyonu\r\nexport const pickFile = async (options: DocumentPickerOptions = {}): Promise<FileInfo[]> => {\r\n if (!NativeUploadPicker) throw new Error(\"DocumentPicker module is not linked.\");\r\n\r\n // Native tarafa gönderilecek options\r\n const nativeOptions = {\r\n multipleFiles: options.multipleFiles ?? false,\r\n maxFiles: options.maxFiles ?? 0,\r\n maxSize: options.maxSize ?? 0,\r\n fileTypes: options.fileTypes ?? ['*/*'],\r\n excludedUris: options.excludedUris ?? [],\r\n isGallery:options.isGallery ?? false,\r\n withBase64:options.withBase64 ?? true,\r\n };\r\n\r\n return await NativeUploadPicker.openDocument(nativeOptions);\r\n};\r\n\r\nexport const getBase64FromUri = async (cropFileUri: string): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.getBase64FromUri(cropFileUri);\r\n } catch (error: any) {\r\n throw new Error(`getBase64FromUri Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n\r\nexport const CropImageWithBase64 = async (base64: string,cropData:any): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n return await NativeUploadPicker.CropImageWithBase64(base64,cropData);\r\n } catch (error: any) {\r\n throw new Error(`CropImageWithBase64 Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n\r\n \r\n\r\nexport const RotateImage = async ({ base64, angle }: RotateImageProps): Promise<string> => {\r\n if (!NativeUploadPicker) {\r\n throw new Error(\"UploadDocumentPicker modülü linklenmemiş.\");\r\n }\r\n\r\n try {\r\n // Native sadece saf base64 string'i döner\r\n const rotatedBase64: string = await NativeUploadPicker.rotateImage(base64, angle);\r\n\r\n // Uygulama tarafında doğrudan <Image /> içinde kullanılabilmesi için prefix eklenir\r\n return `data:image/jpeg;base64,${rotatedBase64}`;\r\n } catch (error: any) {\r\n // Hata mesajını daha okunaklı fırlatıyoruz\r\n throw new Error(`RotateImage Hatası: ${error.message}`);\r\n }\r\n};\r\n\r\n// 2. MyUploader Bileşeni\r\nconst MyUploader: React.FC<MyUploaderProps> = ({\r\n onSelect,\r\n onError,\r\n buttonPlaceHolder = \"Dosya Seç\",\r\n ButtonStyle,\r\n ButtonTextStyle,\r\n disabled = false,\r\n multipleFiles = false,\r\n fileTypes = ['*/*'],\r\n maxSize = 0,\r\n maxFiles = 0,\r\n excludedUris = [],\r\n}) => {\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handlePress = async () => {\r\n if (disabled || isLoading) return;\r\n setIsLoading(true);\r\n\r\n try {\r\n const files = await pickFile({\r\n multipleFiles,\r\n fileTypes,\r\n maxSize,\r\n maxFiles,\r\n excludedUris\r\n });\r\n\r\n onSelect(files);\r\n } catch (error: any) {\r\n if (onError) {\r\n onError(error);\r\n } else {\r\n console.error(\"MyUploader Error:\", error);\r\n }\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <TouchableOpacity\r\n style={[styles.button, ButtonStyle, (disabled || isLoading) && styles.disabled]}\r\n onPress={handlePress}\r\n disabled={disabled || isLoading}\r\n >\r\n {isLoading ? (\r\n <ActivityIndicator color=\"#FFF\" />\r\n ) : (\r\n <Text style={[styles.text, ButtonTextStyle]}>{buttonPlaceHolder}</Text>\r\n )}\r\n </TouchableOpacity>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n button: {\r\n backgroundColor: '#6200EE',\r\n padding: 12,\r\n borderRadius: 8,\r\n alignItems: 'center',\r\n justifyContent: 'center'\r\n },\r\n text: {\r\n color: '#FFF',\r\n fontWeight: '600',\r\n fontSize: 16\r\n },\r\n disabled: {\r\n backgroundColor: '#B0B0B0'\r\n }\r\n});\r\n\r\nexport default MyUploader;"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,gBAAgB,EAAEC,IAAI,EAAEC,UAAU,EAAEC,iBAAiB,EAAEC,aAAa,QAAQ,cAAc;AAGnG,MAAM;EAAEC,oBAAoB,EAAEC;AAAmB,CAAC,GAAGF,aAAa;;AAElE;AACA,OAAO,MAAMG,QAAQ,GAAG,MAAA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EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDN,IAAI,EAAE;IACJD,KAAK,EAAE,MAAM;IACbQ,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDpB,QAAQ,EAAE;IACRc,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;AAEF,eAAepB,UAAU","ignoreList":[]}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n isGallery?:boolean;\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["// import type { StyleProp, TextStyle, ViewStyle } from 'react-native';\r\n\r\n// export interface FileInfo {\r\n// fileName: string;\r\n// fileSize: number; \r\n// fileType: string | null;\r\n// fileUri: string;\r\n// base64: string;\r\n// }\r\n\r\n// export interface MyUploaderProps{\r\n// onSelect: (files: FileInfo[]) => void;\r\n// onError?: (error: Error) => void;\r\n// buttonPlaceHolder?: string;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// disabled?: boolean; \r\n// multipleFiles?: boolean;\r\n// fileTypes?: string[];\r\n// maxSize?: number;\r\n// maxFiles?: number;\r\n// excludedUris?: string[];\r\n// }\r\n\r\n// export interface DownloadedFileInfo {\r\n// originalUrl: string;\r\n// localUri: string;\r\n// }\r\n\r\n// export interface SkippedFileInfo {\r\n// originalUrl: string;\r\n// reason: string; \r\n// }\r\n\r\n\r\n\r\n// export interface UploadFileProps {\r\n// files: string[];\r\n// multipleLoad?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean; \r\n// maxSize?: number;\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: StyleProp<ViewStyle>;\r\n// ButtonTextStyle?: StyleProp<TextStyle>;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: Error) => void;\r\n// }\r\n\r\n// export interface DownloadFileProps {\r\n// files: string[];\r\n// multipleDownload?: boolean;\r\n// disabled?: boolean;\r\n// debug?: boolean;\r\n// maxSize?: number; // MB\r\n// fileTypes?: string[];\r\n// buttonPlaceHolder?: string;\r\n// buttonIcon?: React.ReactNode;\r\n// ButtonStyle?: ViewStyle;\r\n// ButtonTextStyle?: TextStyle;\r\n// onSuccess?: (result: DownloadResult) => void;\r\n// onError?: (error: any) => void;\r\n// }\r\n// export interface DownloadResult {\r\n// successful: { originalUrl: string; localUri: string | null }[];\r\n// skipped: { originalUrl: string; reason: string }[];\r\n// }\r\n\r\n\r\nimport type { ViewStyle, TextStyle } from 'react-native';\r\n\r\nexport interface FileInfo {\r\n fileUri: string;\r\n fileName: string;\r\n fileType: string;\r\n fileSize: number;\r\n base64?: string | null;\r\n}\r\n\r\n\r\n// ----- MyUploader & pickFile Props -----\r\nexport interface DocumentPickerOptions {\r\n multipleFiles?: boolean;\r\n fileTypes?: string[]; // örn: ['image/*', 'application/pdf']\r\n maxSize?: number; // MB cinsinden\r\n maxFiles?: number;\r\n excludedUris?: string[];\r\n isGallery?:boolean;\r\n withBase64?:boolean;\r\n}\r\n\r\nexport interface MyUploaderProps extends DocumentPickerOptions {\r\n onSelect: (files: FileInfo[]) => void;\r\n onError?: (error: Error) => void;\r\n buttonPlaceHolder?: string;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n disabled?: boolean;\r\n}\r\n\r\n// ----- DownloadFile Props -----\r\nexport interface DownloadFileProps {\r\n files: string[];\r\n multipleDownload?: boolean; // multipleFiles yerine multipleDownload (İsim karışmaması için)\r\n disabled?: boolean;\r\n debug?: boolean;\r\n maxSize?: number; // MB\r\n fileTypes?: string[]; // İndirilecek dosyanın Content-Type kontrolü\r\n buttonPlaceHolder?: string;\r\n buttonIcon?: React.ReactNode;\r\n ButtonStyle?: ViewStyle;\r\n ButtonTextStyle?: TextStyle;\r\n onSuccess?: (result: DownloadResult) => void;\r\n onError?: (error: any) => void;\r\n}\r\n\r\n\r\nexport interface DownloadResult {\r\n successful: { originalUrl: string; localUri: string | null }[];\r\n skipped: { originalUrl: string; reason: string }[];\r\n}\r\n\r\n\r\n///rotateImage\r\n\r\nexport interface RotateImageProps{\r\n base64: string, angle: number\r\n}"],"mappings":"","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ export const pickFile = async (options: DocumentPickerOptions = {}): Promise<Fil
|
|
|
16
16
|
fileTypes: options.fileTypes ?? ['*/*'],
|
|
17
17
|
excludedUris: options.excludedUris ?? [],
|
|
18
18
|
isGallery:options.isGallery ?? false,
|
|
19
|
+
withBase64:options.withBase64 ?? true,
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
return await NativeUploadPicker.openDocument(nativeOptions);
|