I think the answer to my second question is no, they have to be unique names. I'll have to unique the file names based on my Field's document ID for each record. Something like this:
"field-ABCDEF123456:Canadian Flag.png" "field-ABCDEF123456:USA Flag.png" "field-ABCDEF123456:British Flag.png" and then even another set for a different field: "field-XYZDEF123456:Canadian Flag.png" "field-XYZDEF123456:USA Flag.png" "field-XYZDEF123456:British Flag.png" Even though the file names after the : are the same, they may be different files within the same record. For example, a smaller and larger version of the same file or even two different styles. Then if the user deletes the file attachment Field object from their form, I can search all records for any attachments with names that start with that field's document id "field-ABCDEF123456" (or whatever) and delete the actual file. And I guess if they delete the record itself then CBL would handle deleting all the attachments for that record by itself I think. Sorry if I'm spamming the list. Hopefully these questions are useful to others too. I don't have anyone else to work these things out and I find this helps just to type it out. Thanks! Brendan On Sunday, June 14, 2015 at 8:29:21 PM UTC-6, Brendan Duddridge wrote: > > Hi Jens, > > The Attachments directory is a content-addressable store. Attachments are >> named by their SHA-1 digests, and any attachments with the same contents in >> a database (even if they have different filenames or types) will be stored >> as the same file. That should make it clear why attachment files should >> never be modified! > > > Interesting. So if I allow the user to say, double-click on an attachment > to view it in Preview (for say a PDF file), then they make a change to the > file such as mark it up and then save it, what would happen in CBL? A user > could theoretically just navigate directly to the file and edit it too. I > couldn't stop that from happening. Would the sync system still push an > update to the gateway with the changes? > > Also, can you have multiple attachments with the same name? Currently my > attachments are stored in separate folders, so you can have the same file > name attached, but in different folders. But I'm seriously thinking about > using CB attachments because then I don't have to worry about syncing file > attachments independently of the database syncing. > > Thanks! > > Brendan > > > > > -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/058c2244-14eb-4b5a-822f-b1a1a7af88ce%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
