Is using CoreData + CloudKit to store text notes and iCloud Document to store note image attachments as image files a good design approach?
Currently, I have almost finished implementing the app to store text notes as Core Data and note image attachments as image files.
I like to provide iCloud storage support to the app. I come across a few app examples
-
https://www.raywenderlich.com/13219461-getting-started-with-core-data-and-cloudkit
-
https://developer.apple.com/documentation/coredata/synchronizing_a_local_store_to_the_cloud
Both examples are using CoreData + CloudKit to store the image as SQLite blob binary data which CoreData will perform such task automatically)
I'm aware that when storing the binary image into CoreData, CoreData is smart enough to choose either to store it as a binary blob in SQLite, or an external file.
However, I am a little skeptical about such an approach
-
We are using Kingfisher for smooth image loading in the collection view. If the image data are not in a regular flat-file, how can we integrate CoreData's blob data with Kingfisher?
-
Storing images in CoreData seems like a black box. If something goes wrong in between, it is hard to debug where and how goes wrong.
-
We like to provide alternative cloud storage (using cloud S3 storage to store SQLite files and multiple images) for the app. So, saving the image as flat files will make such an effort easier.
-
Some related discussion on storing the image in DB vs flat files - https://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay
I would prefer
-
Only use CoreData + CloudKit to store the text note and file path.
-
The image file will store in both the app folder and the iCloud document folder (so that it syncs seamlessly to iCloud). If the required images are not in the app folder (App uninstall, then re-install), the app will try to copy the image file from the iCloud document
I was wondering, anyone of you has tried such a design in your app? Do you find it is a good approach based on your experience?
Thanks.