Hi all,
Really good stuff on this site and I’ve been working with a couple of the examples.
Yet, I’m struggling on how to retrieve an attachment from a CouchDB in Swift.
I understand that CouchDB has a kind of ‘flag’ (called stub) to indicate that there is an attachment.
In the JSON structure I get back from CouchDB I can spot under the key “_attachments” metadata (Content-Type, length etc.
I know how to retrieve that attachment from the CLI (curl -X GET ip:port{id}/{attachment_file}) but I’m drawing a blind how to do it from Swift.
the code to go through the results of a database.retrieveAll() call:
if let docs = docs {
for document in docs["rows"].arrayValue {
var plaatje = [String: Any]()
plaatje["ordernum"] = document["doc"]["orderNumber"].stringValue
plaatje["img"] = // what to put here?????
plaatjes.append(plaatje)
}
}
Is there a method of the database instance or any other way to get the binary of the attachment?
Many thanks!
__Frank