How to save image to gallery iOS
I have image as byte array, how to save it to gallery iOS?? help please
Hi @BoikoIlya!
By using the Save File Picker UI, you can do it like explain in the documentation:
val image: ByteArray
// FileKit Core
val file = FileKit.saveFile(
baseName = "image",
extension = "png",
initialDirectory = "/custom/initial/path",
bytes = image
)
// FileKit Compose
val launcher = rememberFileSaverLauncher() { file ->
// Handle the saved file
}
launcher.launch(
baseName = "image",
extension = "png",
initialDirectory = "/custom/initial/path",
bytes = image
)
And you need to find a way to get the url of the gallery in iOS that you can pass it to initialDirectory parameter.
If you want to save direct bytes to a file without using picker UI, you'll need to code this yourself as it's not supported yet with FileKit.
this may help: https://github.com/fethij/Rijksmuseum/blob/main/feature/arts/src/iosMain/kotlin/Utils.ios.kt#L47
It's now possible to save an image to the gallery on Android and iOS using FileKit version 0.10.0-beta01.
You can read the documentation here: https://filekit.mintlify.app/core/image-utils#saving-images-to-gallery