Fix file parts to not include invalid newlines.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent e3014ece84
commit 769849b11f
  1. 5
      scripts/md5
  2. 15
      src/sig/MultipartUtility.java
  3. 10
      utils/md5

@ -1,5 +0,0 @@
build.sh:a833e7598ad65672a9c01306d244b49f -
clean.sh:96ce35f2d2dcb555421e00a6afda23ca -
commit.sh:21af1fa6f09d01679c9e11408967264a -
jar.sh:2ac636f584c43a1124affb9ea6bdc7bf -
lean.sh:3be7b8b182ccd96e48989b4e57311193 -

@ -92,19 +92,18 @@ public class MultipartUtility {
+ URLConnection.guessContentTypeFromName(fileName)) + URLConnection.guessContentTypeFromName(fileName))
.append(LINE_FEED); .append(LINE_FEED);
writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED); writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED);
writer.append(LINE_FEED);
writer.flush(); writer.flush();
FileInputStream inputStream = new FileInputStream(uploadFile); FileInputStream inputStream = new FileInputStream(uploadFile);
byte[] buffer = new byte[4096]; char[] buffer = new char[1024];
String s = new String(buffer);
byte[] data = s.getBytes("ISO-8859-1");
int bytesRead = -1; int bytesRead = -1;
while ((bytesRead = inputStream.read(buffer)) != -1) { while ((bytesRead = inputStream.read(data)) > 0) {
outputStream.write(buffer, 0, bytesRead); outputStream.write(data, 0, bytesRead);
} }
outputStream.flush();
inputStream.close(); inputStream.close();
writer.append(LINE_FEED);
writer.flush(); writer.flush();
} }
@ -127,7 +126,7 @@ public class MultipartUtility {
public List<String> finish() throws IOException { public List<String> finish() throws IOException {
List<String> response = new ArrayList<String>(); List<String> response = new ArrayList<String>();
writer.append(LINE_FEED).flush(); writer.flush();
writer.append("--" + boundary + "--").append(LINE_FEED); writer.append("--" + boundary + "--").append(LINE_FEED);
writer.close(); writer.close();
@ -143,7 +142,7 @@ public class MultipartUtility {
reader.close(); reader.close();
httpConn.disconnect(); httpConn.disconnect();
} else { } else {
throw new IOException("Server returned non-OK status: " + status); System.out.println("Server returned non-OK status: " + status);
} }
return response; return response;

@ -1,5 +1,5 @@
.coauthors:3785ad38663e5fc43e574914ad067294 - .coauthors:49b0c10f391bb8115cedf6080339e858 *-
define.sh:d6b20a25a04a60d94f466e48fa60ac69 - .updateDirectories:9312534cebd2bbec7ec381ed3815000f *-
main.sh:32a1f953ffca8584d1eb57c0ecd8a582 - define.sh:2e7597637a9f22d539eba4486e5b4449 *-
search.sh:28d0ede8345514d80cc68cc756870002 - main.sh:40565c4dcc6349eb29a3834d9e199edc *-
.updateDirectories:0ede00461e947494545e694040787b3f - search.sh:92ed16b507d9ba3eddbf026231fec151 *-

Loading…
Cancel
Save