String currentUserName = serviceRegistry.getAuthenticationService().getCurrentUserName();
props.put(ContentModel.PROP_CREATOR, currentUserName);
props.put(ContentModel.PROP_AUTHOR, currentUserName);
props.put(ContentModel.PROP_OWNER, currentUserName);
serviceRegistry.getNodeService().setProperties(fileNodeRef, props);
ContentWriter writer = serviceRegistry.getContentService().getWriter(fileNodeRef, ContentModel.PROP_CONTENT,
true);
String mimeType = serviceRegistry.getMimetypeService().guessMimetype(fileName);
writer.setMimetype(mimeType);
writer.setEncoding(content.getEncoding());
writer.putContent(content.getInputStream());
}