/** * Encodes content of the supplied InputStream into Base64 notation. Does not GZip-compress data. * * @param source The data to convert * @return the encoded bytes */ public static String encode( java.io.InputStream source ) { return encode(source, NO_OPTIONS); }
/** * Return the JSON-compatible string representation of the given property value. If the value is a {@link PropertyType#BINARY * binary} value, then this method returns the Base-64 encoding of that value. Otherwise, it just returns the string * representation of the value. * * @param value the property value; may not be null * @return the string representation of the value * @throws RepositoryException if there is a problem accessing the value */ private String jsonEncodedStringFor( Value value ) throws RepositoryException { // Encode the binary value in Base64 ... InputStream stream = value.getStream(); try { return Base64.encode(stream); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { // Error accessing the value, so throw this ... throw new RepositoryException(e); } } } }