Created
November 14, 2023 10:58
-
-
Save ansisec/47f1761bc661e7e373049c76e3035a67 to your computer and use it in GitHub Desktop.
P07 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Utils { | |
companion object { | |
fun getTempFilename(context: Context) : String = | |
File.createTempFile( | |
"image", ".img", | |
context.externalCacheDir | |
).absolutePath | |
fun createFileFromUri( | |
context: Context, | |
uri : Uri, | |
filename : String = getTempFilename(context) | |
) : String { | |
FileOutputStream(filename).use { outputStream -> | |
context.contentResolver.openInputStream(uri)?.use { inputStream -> | |
inputStream.copyTo(outputStream) | |
} | |
} | |
return filename | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment