Commit 9a238861 authored by Quxl's avatar Quxl

x

parent a212a30e
...@@ -298,8 +298,11 @@ public class HttpUtil { ...@@ -298,8 +298,11 @@ public class HttpUtil {
return StringUtil.join("&", params); return StringUtil.join("&", params);
} }
public static String post(String requestUrl, Map<String, Object> parameters, Map<String, String> headers, public static String post(String requestUrl, Map<String, Object> parameters, Map<String, String> headers, Map<String, File> attachments) {
Map<String, File> attachments, String contentType) { return post(requestUrl, parameters, headers, attachments, "application/octet-stream");
}
public static String post(String requestUrl, Map<String, Object> parameters, Map<String, String> headers, Map<String, File> attachments, String contentType) {
HttpURLConnection connection = null; HttpURLConnection connection = null;
try { try {
Data data = new Data(); Data data = new Data();
...@@ -320,9 +323,8 @@ public class HttpUtil { ...@@ -320,9 +323,8 @@ public class HttpUtil {
StringBuffer FileBuffer = new StringBuffer(); StringBuffer FileBuffer = new StringBuffer();
File file = attachments.get(name); File file = attachments.get(name);
FileBuffer.append("--" + BOUNDARY + "\r\n"); FileBuffer.append("--" + BOUNDARY + "\r\n");
FileBuffer.append("Content-Disposition: form-data; name=\"" + name + "\"; filename=\"" FileBuffer.append("Content-Disposition: form-data; name=\"" + name + "\"; filename=\"" + file.getName() + "\"" + "\r\n");
+ file.getName() + "\"" + "\r\n"); FileBuffer.append("Content-Type:" + contentType + "\r\n");
FileBuffer.append("Content-Type:" + contentType + "" + "\r\n");
FileBuffer.append("\r\n"); FileBuffer.append("\r\n");
String FileBufferString = FileBuffer.toString(); String FileBufferString = FileBuffer.toString();
data.add(FileBufferString.getBytes()); data.add(FileBufferString.getBytes());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment