Removing attachments from CBL

In order to save space on a clients device I’d like to be able to remove attachments that fit a certain criteria, basically the ones that haven’t been viewed in a while. The attachments aren’t to be deleted from the server as the client may need them at a later date. So the clients also need a way of “re-getting” the attachments them after they’ve been removed.

Is there a recommended way to achieve this? I can do it on my server, or the client, or both even.

You’re using the Obj-C version, right? It has an unofficial CBLAttachment method to purge the data:

/** Deletes the attachment's contents from local storage. If the attachment is still available on
    a remote server, it can be restored by calling -[CBLReplication downloadAttachment:onProgress:].
 */
- (BOOL) purge;

I need a solution that works on android and ios. Ideally, if it’s a client side solution then via the rest API.

You’d have to purge the document(s) that use the attachment, then compact the database.

Ok, so on the client i purge the docs containing the attachments and compact the database, understood - thanks.

What would happen then if the document was subsequently modified and the client has continuous replication turned on? Would they simply receive and update of the document and it’s attachments via the _changes feed, just like a normal update?

Yes, exactly. Once it’s changed, any pull replication would download the document & attachment.

Ok, many thanks that’s helpful.