Hi,
I'm writing an export routine which generates a big JSON file. I need to extract file attachments from the database now and store them into a folder along side the JSON file. Is there a way to get access to the following method?
+ (bool) digest: (NSString*)digest toBlobKey: (CBLBlobKey*)outKey;
I'm assuming that is will take the digest as provided by the metadata from the CBLAttachment and give me a filename that I can read from? I don't want to store the files with the original filename because I might have file attachments from different documents with the same attachment name, but are actually different files.
So I thought I would do something similar to what CBL already does with naming attachments. But since the data I have in the JSON file is whatever the CBLAttachment metadata is, I would like to figure out how to name the attachments correctly so that when I import the JSON file I'm able to determine from the digest what attachment file to read in.
Here's an example of what my attachments JSON looks like:
"_attachments": {
"icon": {
"stub": true,
"length": 6411,
"digest": "sha1-/wxjDAVSpOaf7qN7SWuqNZ4IM78=",
"revpos": 1,
"content_type": "image/png"
}
}
"icon" is just the name I give an icon that I associate with one of my model objects. But it could be a regular file name such as "hunger-games.jpg" or "terminator.png", etc.
Thanks,
Brendan