Morrowless
Morrowless

Reputation: 6958

Storing blobs in external location using built-in CoreData option

I have managed objects that have image properties. Since storing large blobs in CoreData is a bad idea, I'm trying to use the built-in CoreData option "Store in External Record File" which you can see in the Data Model Inspector.

Despite enabling this option, I do not see any image data being stored externally. Judging by the size, it seems like they are still being saved in the sqlite file. What is the issue?

Upvotes: 13

Views: 5538

Answers (2)

marcusg
marcusg

Reputation: 586

If your store type is NSSQLiteStoreType, your attribute is NSBinaryDataAttributeType. You have enabled setAllowsExternalBinaryDataStorage and your object data size is larger then approximately 1MB.

  • Objects that are smaller than 1MB are stored in the sqlite database.
  • Objects that are larger are just a reference to a external file.

You'll find the (external) files in a hidden sub-directory at the same location as the persistent store.

<path>/<database>.sqlite
<path>/<your_database>_SUPPORT/_EXTERNAL_DATA/

Upvotes: 26

Allamaprabhu
Allamaprabhu

Reputation: 865

sqlite2 does not allow size of BLOB data to be more than 1MB,However sqlite 3 allows larger BLOB.First check out which version of sqlite u r using. And if ur file is in MB's i would rather prefer them storing in local database instead.

Upvotes: 0

Related Questions