Skip to content

Commit a4b8152

Browse files
committed
Isolation of Base64 functions
1 parent e0be99d commit a4b8152

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.fugerit.java.doc.base.helper;
2+
3+
import org.apache.commons.codec.binary.Base64;
4+
5+
public class Base64Helper {
6+
7+
public static String encodeBase64String( byte[] data ) {
8+
return Base64.encodeBase64String( data );
9+
}
10+
11+
public static byte[] decodeBase64String( String data ) {
12+
return Base64.decodeBase64( data );
13+
}
14+
15+
}

fj-doc-base/src/main/java/org/fugerit/java/doc/base/helper/SourceResolverHelper.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.net.URL;
44

5-
import org.apache.commons.codec.binary.Base64;
65
import org.fugerit.java.core.io.StreamIO;
76
import org.fugerit.java.core.io.helper.StreamHelper;
87
import org.fugerit.java.core.lang.helpers.StringUtils;
@@ -23,7 +22,7 @@ public static String resolveImageToBase64( DocImage img ) throws Exception {
2322
URL url = new URL( path );
2423
data = StreamIO.readBytes( url.openConnection().getInputStream() );
2524
}
26-
base64 = Base64.encodeBase64String( data );
25+
base64 = Base64Helper.encodeBase64String( data );
2726
} else {
2827
throw new Exception( "Null path and base64 provided!" );
2928
}
@@ -35,7 +34,7 @@ public static byte[] resolveImage( DocImage img ) throws Exception {
3534
String path = img.getUrl();
3635
String base64 = img.getBase64();
3736
if ( StringUtils.isNotEmpty( base64 ) ) {
38-
data = Base64.decodeBase64( base64 );
37+
data = Base64Helper.decodeBase64String( base64 );
3938
} else if ( path != null ) {
4039
if ( path.startsWith( StreamHelper.PATH_CLASSLOADER ) ) {
4140
data = StreamIO.readBytes( StreamHelper.resolveStream( path ) );

0 commit comments

Comments
 (0)