LargeFileUtils { public URI parseBase64DataAsUri(DataHandler dh) throws URISyntaxException { String uriString = ""; try (InputStream is = dh.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream()) { int numRead = 1024; byte[] buf = new byte[numRead]; if ((numRead = is.read(buf)) >= 0) { baos.write(buf, 0, numRead); } uriString = StringUtil.convertToStringUTF8(baos.toByteArray()); } catch (IOException e) { LOG.error("IOException occurred while parsing Base64 Data for URI String", e); } return new URI(uriString); }  static LargeFileUtils getInstance(); boolean isParsePayloadAsFileLocationEnabled(); boolean isSavePayloadToFileEnabled(); URI parseBase64DataAsUri(DataHandler dh); File saveDataToFile(DataHandler dh); void saveDataToFile(DataHandler dh, File file); void closeStreamWithoutException(InputStream is); void closeStreamWithoutException(OutputStream os); DataHandler convertToDataHandler(File file); DataHandler convertToDataHandler(String data); DataHandler convertToDataHandler(byte[] data); byte[] convertToBytes(DataHandler dh); File generateAttachmentFile(); File generateAttachmentFile(String payloadSaveDirectory);  }
@Test public void testParseBase64DataAsUri() throws IOException, URISyntaxException { String URI_STRING = "file: LargeFileUtils fileUtils = new LargeFileUtils(); DataHandler dh = fileUtils.convertToDataHandler(URI_STRING); URI uri = fileUtils.parseBase64DataAsUri(dh); assertEquals(uri.toString(), URI_STRING); }