mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 22:38:00 +01:00
Fix error in legacy skin uploads
This commit is contained in:
parent
8c03c42a3a
commit
5b837150aa
1 changed files with 7 additions and 2 deletions
|
@ -6,12 +6,15 @@ import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,11 +83,13 @@ public class ThreadMultipartPostUpload {
|
||||||
String paramName = data.getKey();
|
String paramName = data.getKey();
|
||||||
Object paramData = data.getValue();
|
Object paramData = data.getValue();
|
||||||
|
|
||||||
if (paramData instanceof Path) {
|
if (paramData instanceof URI) {
|
||||||
Path uploadPath = (Path) paramData;
|
Path uploadPath = Paths.get((URI) paramData);
|
||||||
|
|
||||||
outputStream.writeBytes("Content-Disposition: form-data; name=\"" + paramName + "\"; filename=\"" + uploadPath.getFileName() + "\"" + CRLF);
|
outputStream.writeBytes("Content-Disposition: form-data; name=\"" + paramName + "\"; filename=\"" + uploadPath.getFileName() + "\"" + CRLF);
|
||||||
outputStream.writeBytes("Content-Type: image/png" + CRLF + CRLF);
|
outputStream.writeBytes("Content-Type: image/png" + CRLF + CRLF);
|
||||||
|
|
||||||
|
|
||||||
Files.copy(uploadPath, outputStream);
|
Files.copy(uploadPath, outputStream);
|
||||||
} else {
|
} else {
|
||||||
outputStream.writeBytes("Content-Disposition: form-data; name=\"" + paramName + "\"" + CRLF + CRLF);
|
outputStream.writeBytes("Content-Disposition: form-data; name=\"" + paramName + "\"" + CRLF + CRLF);
|
||||||
|
|
Loading…
Reference in a new issue