mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 14:27:59 +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.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);
|
||||
|
|
Loading…
Reference in a new issue