Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save image to gallery iOS #100

Open
BoikoIlya opened this issue Aug 30, 2024 · 2 comments
Open

How to save image to gallery iOS #100

BoikoIlya opened this issue Aug 30, 2024 · 2 comments
Labels
next Scheduled for the next version

Comments

@BoikoIlya
Copy link

I have image as byte array, how to save it to gallery iOS?? help please

@vinceglb
Copy link
Owner

vinceglb commented Sep 2, 2024

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.

@fethij
Copy link

fethij commented Oct 1, 2024

this may help: https://github.com/fethij/Rijksmuseum/blob/main/feature/arts/src/iosMain/kotlin/Utils.ios.kt#L47

@vinceglb vinceglb added the next Scheduled for the next version label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next Scheduled for the next version
Projects
None yet
Development

No branches or pull requests

3 participants