mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-04 20:42:48 +02:00
Removed splitFileName function as both file name and extension are known separately
This commit is contained in:
@@ -35,9 +35,7 @@ object MediaCompressorFileUtils {
|
||||
context: Context,
|
||||
): File {
|
||||
val extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(context.contentResolver.getType(uri)) ?: ""
|
||||
val fileName = UUID.randomUUID().toString() + ".$extension"
|
||||
val (name, ext) = splitFileName(fileName)
|
||||
val tempFile = File.createTempFile(name, ext)
|
||||
val tempFile = File.createTempFile(UUID.randomUUID().toString(), extension)
|
||||
|
||||
context.contentResolver.openInputStream(uri)?.use { inputStream ->
|
||||
FileOutputStream(tempFile).use { outputStream ->
|
||||
@@ -54,13 +52,4 @@ object MediaCompressorFileUtils {
|
||||
) {
|
||||
input.copyTo(output, bufferSize = 1024 * 50)
|
||||
}
|
||||
|
||||
private fun splitFileName(fileName: String): Pair<String, String> {
|
||||
val i = fileName.lastIndexOf(".")
|
||||
return if (i != -1) {
|
||||
fileName.substring(0, i) to fileName.substring(i)
|
||||
} else {
|
||||
fileName to ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user