Skip to content

Commit

Permalink
Fixed path serialization issue
Browse files Browse the repository at this point in the history
  • Loading branch information
akulyakhtin authored and sashirestela committed May 16, 2024
1 parent ac67bd9 commit d6f8127
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.sashirestela</groupId>
<artifactId>cleverclient</artifactId>
<version>1.4.2</version>
<version>1.4.3</version>
<packaging>jar</packaging>

<name>cleverclient</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import io.github.sashirestela.cleverclient.util.Constant;

import java.io.IOException;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -36,11 +37,12 @@ public static List<byte[]> toByteArrays(Map<String, Object> data) {
String mimeType = null;
byte[] fileContent = null;
try {
var path = Path.of(new URL((String) entry.getValue()).getPath());
URI uri = new URI(entry.getValue().toString());
var path = Paths.get(uri);
fileName = path.toString();
mimeType = Files.probeContentType(path);
fileContent = Files.readAllBytes(path);
} catch (IOException e) {
} catch (IOException | URISyntaxException e) {
throw new CleverClientException("Error trying to read the file {0}.", fileName, e);
}
byteArrays.add(toBytes(FIELD_NAME + DQ + fieldName + DQ + FILE_NAME + DQ + fileName + DQ + NL));
Expand Down

0 comments on commit d6f8127

Please sign in to comment.