使用内置的CoreData选项将Blob存储在外部位置 [英] Storing blobs in external location using built-in CoreData option

查看:127
本文介绍了使用内置的CoreData选项将Blob存储在外部位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经管理有图像属性的对象。因为在CoreData中存储大的blob是一个坏主意,我试图使用内置的CoreData选项存储在外部记录文件,您可以在数据模型检查器中看到。



虽然启用了此选项,但我没有看到任何外部存储的图像数据。根据大小判断,似乎它们仍然保存在sqlite文件中。

如果你的商店类型是 NSSQLiteStoreType ,那么,您的属性为 NSBinaryDataAttributeType 。您已启用 setAllowsExternalBinaryDataStorage ,且您的对象数据大小大于约1MB。




  • 小于1MB的对象存储在sqlite数据库中。

  • 较大的对象只是对外部文件的引用。



您可以在与永久存储相同位置的隐藏子目录中找到(外部)文件。

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


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?

解决方案

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/

这篇关于使用内置的CoreData选项将Blob存储在外部位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆