-
Enhancement
-
Resolution: Done
-
Major
-
3.7.1.Final
-
None
Current REST API does not allow an efficient creation of nodes with a binary content. To create a nt:file node with a large binary content Modeshape needs a lot of memory, approx. 3 x size of the content - an overhead of Base64 encoding and converting a whole request to a String object (java.lang String uses UTF-16 as an internal representation).
For my current customer I've created a custom REST handler which uses Jackson's streaming parser, specifically JsonParser#readBinaryValue. If you are interested I could ask about permission to contribute this code to ModeShape project (needs a lot of polishing though). It would be nice to use the current JSON parser (Jettison) but AFAIK it doesn't allow such efficient document processing.
Note: REST API gives this (https://docs.jboss.org/author/display/MODE/REST+Service+3.x#RESTService3.x-18.Createabinaryproperty%28viarequestcontent%29) but I don't think that you can create nt:file (specifically a nt:resource child) this way due to a mandatory jcr:data property. A possible workaround could be:
- create a nt:file node with an empty binary content,
- update the binary content with https://docs.jboss.org/author/display/MODE/REST+Service+3.x#RESTService3.x-19.Updateabinaryproperty%28viarequestcontent%29.
It's pretty convoluted though and the operation isn't atomic anymore.
I'm aware of https://issues.jboss.org/browse/MODE-1583 - anyway, I don't think it resolves an above case. Did I missed something?