-
Hello! I'm currently working on a mobile app that uses an encrypted Realm DB and we're now looking at what our options are for storing files (<= 5MB), like pictures or PDFs. The Realm DB mainly handles transitory data—anything the user wants to actually save will be uploaded to a server, so we aren't concerned with long-term storage. Right now, I see two options: 1. Store file in Realm
2. Store file in file system and store its filepath in Realm
Questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Are you using Atlas Device Sync or are you just using the local database with a custom server? Asking mainly because we have a project coming that will simplify storing binary data by uploading the structured data to Atlas while at the same time uploading the binary files to S3/whatever other storage server you want to use. |
Beta Was this translation helpful? Give feedback.
-
Realm uses standard AES256 encryption, where the first 32 bytes of the supplied encryption key are used for the AES encryption, while the second 32 bytes are used for HMAC integrity validation. Here's a straightforward tutorial for implementing the encryption part in C#: https://www.jasonpenniman.com/aes256-encryption-csharp - you'll need to change it a bit so that you work with byte[]/Stream rather than strings, but the core concepts should be fairly easy to translate. |
Beta Was this translation helpful? Give feedback.
Gotcha, we're still in the design phase of this project, so not sure how exactly that'll look like for the local database, but we'll use the input here in our considerations.
In terms of the original questions, we generally recommend storing outside of the file as having large blobs will slow things down. Realm files are memory-mapped and we'll need to load more data into memory as there's no way to distinguish between binary and structured data since they are interwoven with one another. There's no cutoff for when performance becomes terrible and instead, the larger the file becomes, the worse performance is. It gets really bad if the files become larger than what can fit into memory, be…