File/Binary Data type within Realm Database
A new type could be defined, such as RealmFile. A RealmObject could have a RealmFile field or even a RealmList<RealmFile> field. Just like all other RealmObjects, this would simply be a proxy and wouldn't contain the actual file/binary data. To access or update the data in the RealmFile you would get an InputStream or OutputStream. Realm handles the rest in terms of syncing, caching, linking, etc. I know that Realm itself isn't really designed for arbitrarily large files, so the data contained in a RealmFile wouldn't necessarily need to be put into Realm. But it would be managed and handled by Realm as if it were. In terms of the backend, I don't know MongoDB's product offering well enough to know whether a file/blob storage backend exists that Realm could plug into.
It would be helpful if there were other attributes on the RealmFile as well, such as the current hash, which would get updated when writing data to the RealmFile. This would be helpful for querying based on a hash.
If there are any concerns about changes to files causing syncing issues, it would still be helpful to have something like a RealmFile that's immutable. In this case, you would only need to deal with an initial upload and a subsequent download on other clients. You wouldn't have to deal with the data changing. (i.e. RealmFile would only have an InputStream, no OutputStream...other than for initial creation)
To be more clear, here's our use case:
We currently have files (e.g. images, PDFs) that never change (they're only created or deleted) as well as a sqlite database. The db references hashes of files. When we create a new file and create or update corresponding db entries these effectively happen independently from one another. We can do the updates within a sqlite transaction, but there's no way to roll back the file operations if something fails. In addition, we keep track of when the last db entry that references a specific file hash is removed and we then delete the corresponding file.
If these files could effectively be linked with a RealmObject, then we could perform safe transactions and Realm would handle syncing, caching, deleting, etc.