in src/main/java/org/apache/sling/distribution/journal/binary/jcr/JcrBinaryStore.java [117:135]
public String store(String id, InputStream binaryStream)throws DistributionException {
try (ResourceResolver resolver = createResourceResolver()) {
String pkgPath = PACKAGES_ROOT_PATH + "/" + id;
Resource pkgResource = ResourceUtil.getOrCreateResource(resolver,
pkgPath, SLING_FOLDER, SLING_FOLDER, false);
Node pkgNode = Objects.requireNonNull(pkgResource.adaptTo(Node.class));
Node binNode = JcrUtils.getOrAddNode(pkgNode, "bin", NodeType.NT_FILE);
Node cntNode = JcrUtils.getOrAddNode(binNode, Node.JCR_CONTENT, NodeType.NT_RESOURCE);
Binary binary = pkgNode.getSession().getValueFactory().createBinary(binaryStream);
cntNode.setProperty(Property.JCR_DATA, binary);
resolver.commit();
String blobRef = ((ReferenceBinary) binary).getReference();
LOG.info("Stored content package {} under path {} with blobRef {}",
id, pkgPath, blobRef);
return blobRef;
} catch (Exception e) {
throw new DistributionException(e.getMessage(), e);
}
}