Does there exist an example usage of storing/reading an attachment through the SRP API?
With the how-to samples on Github, specifically the TodoMVC sample, I've been able to figure out how to CRUD UGC in MongoDB through the SRP API in our custom components. However, I'm really not sure how to, or what the best practices are for, upload image attachments from custom UGC components.
Right now I'm using the same method I wrote for storing the post but one level down, with a random md5 hash of the current timestamp + filename, and storing the image data as a byte array. This just throws it into the same collection as the rest of the UGC though, and just looking at the Storage Configuration options, there's clearly a separate collection just for attachments.
Whether it was storing the value as an InputStream instead of a byte array (byte) or storing the key as "nt:file" (JcrConstants.NT_FILE), it worked.
As an aside... I'm still extremely confused on what some of the key mappings are between Java and MongoDB. For example, "mimetype" all lowercase translates to "content-type" through the SRP API. These pieces are extremely unclear and not straight forward at all. 😞