获取" MIME多部分流的意外结束。 MIME多部分邮件不完整"使用httpurlconnection
从客户端上传zip文件时服务器端的异常以下是上传代码
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type", "multipart/form- data; boundary=" + boundary);
connection.setRequestProperty("Accept-Encoding","gzip, deflate");
connection.setRequestProperty("Accept","*/*");
connection.setRequestProperty("Accept-Language","en-GB,en-US; q=0.8,en; q=0.6");
outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.writeBytes(boundary + LINE_FEED);
String [] q = fileName.split("/");
int ind = q.length-1;
outputStream.writeBytes("Content-Disposition: form-data; name=\"logs\"; filename=\"" +q[ind] + "\""+ LINE_FEED);
outputStream.writeBytes("Content-Type: application/octet-stream "+LINE_FEED);
outputStream.writeBytes(LINE_FEED);
FileInputStream is = new FileInputStream(uploadFile);
byte[] buffer = new byte[4096];
int bytes_read = -1;
while((bytes_read = is.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytes_read);
}
outputStream.writeBytes(LINE_FEED);
outputStream.writeBytes(boundary);
responseMsg = connection.getResponseMessage();
使用邮递员上传同一文件时,文件上传成功