react-native-my-uploader-android 1.0.53 → 1.0.54
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.
|
@@ -635,6 +635,32 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
635
635
|
|
|
636
636
|
override fun onNewIntent(intent: Intent) {}
|
|
637
637
|
|
|
638
|
+
private fun copyFileToInternalStorage(uri: Uri, originalFileName: String): String? {
|
|
639
|
+
return try {
|
|
640
|
+
val inputStream = reactContext.contentResolver.openInputStream(uri) ?: return null
|
|
641
|
+
|
|
642
|
+
// Dosya isminin çakışmaması için timestamp ekliyoruz
|
|
643
|
+
val uniqueFileName = "picked_${System.currentTimeMillis()}_$originalFileName"
|
|
644
|
+
val tempFile = File(reactContext.cacheDir, uniqueFileName)
|
|
645
|
+
|
|
646
|
+
val outputStream = FileOutputStream(tempFile)
|
|
647
|
+
|
|
648
|
+
// Stream kopyalama işlemi (Hafıza dostu)
|
|
649
|
+
inputStream.use { input ->
|
|
650
|
+
outputStream.use { output ->
|
|
651
|
+
input.copyTo(output)
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// file:///... formatında URI döndürür
|
|
656
|
+
Uri.fromFile(tempFile).toString()
|
|
657
|
+
} catch (e: Exception) {
|
|
658
|
+
Log.e("MyUploader", "Kalıcı kopyalama hatası: ${e.message}")
|
|
659
|
+
null
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
|
|
638
664
|
private fun processSelectedFiles(uris: List<Uri>): WritableArray {
|
|
639
665
|
val fileObjects = WritableNativeArray()
|
|
640
666
|
val maxSizeBytes = (maxSize * 1024 * 1024).toLong()
|
|
@@ -670,11 +696,14 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
670
696
|
null
|
|
671
697
|
}
|
|
672
698
|
|
|
699
|
+
val internalFileUri = copyFileToInternalStorage(uri, fileName) ?: uri.toString()
|
|
700
|
+
|
|
701
|
+
|
|
673
702
|
val fileMap = WritableNativeMap().apply {
|
|
674
703
|
putString("fileName", fileName)
|
|
675
704
|
putDouble("fileSize", if (trueSize > 0) trueSize.toDouble() else fileSize.toDouble())
|
|
676
705
|
putString("fileType", mimeType)
|
|
677
|
-
putString("fileUri",
|
|
706
|
+
putString("fileUri", internalFileUri)
|
|
678
707
|
if (withBase64 && base64 != null) {
|
|
679
708
|
putString("base64", base64)
|
|
680
709
|
}
|