From 5b837150aa2f07c815aaa0b4bb8a4077b046a884 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Sun, 22 Jul 2018 16:02:27 -0400 Subject: [PATCH] Fix error in legacy skin uploads --- .../hdskins/upload/ThreadMultipartPostUpload.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/upload/ThreadMultipartPostUpload.java b/src/hdskins/java/com/voxelmodpack/hdskins/upload/ThreadMultipartPostUpload.java index f4030860..d9933a24 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/ThreadMultipartPostUpload.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/upload/ThreadMultipartPostUpload.java @@ -6,12 +6,15 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; +import java.net.URI; import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Map; import java.util.Map.Entry; + import javax.annotation.Nullable; /** @@ -80,11 +83,13 @@ public class ThreadMultipartPostUpload { String paramName = data.getKey(); Object paramData = data.getValue(); - if (paramData instanceof Path) { - Path uploadPath = (Path) paramData; + if (paramData instanceof URI) { + Path uploadPath = Paths.get((URI) paramData); + outputStream.writeBytes("Content-Disposition: form-data; name=\"" + paramName + "\"; filename=\"" + uploadPath.getFileName() + "\"" + CRLF); outputStream.writeBytes("Content-Type: image/png" + CRLF + CRLF); + Files.copy(uploadPath, outputStream); } else { outputStream.writeBytes("Content-Disposition: form-data; name=\"" + paramName + "\"" + CRLF + CRLF);