Skip to content

Commit 007789d

Browse files
authored
Merge pull request #61 from kamaci/master_5
String concatenation is replaced with append() chains.
2 parents 75b7c36 + acbbe7d commit 007789d

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/main/java/io/ipfs/api/Multipart.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ public static String createBoundary() {
4343
}
4444

4545
public void addFormField(String name, String value) {
46-
writer.append("--" + boundary).append(LINE_FEED);
47-
writer.append("Content-Disposition: form-data; name=\"" + name + "\"")
46+
writer.append("--").append(boundary).append(LINE_FEED);
47+
writer.append("Content-Disposition: form-data; name=\"").append(name).append("\"")
4848
.append(LINE_FEED);
49-
writer.append("Content-Type: text/plain; charset=" + charset).append(
50-
LINE_FEED);
49+
writer.append("Content-Type: text/plain; charset=").append(charset).append(LINE_FEED);
5150
writer.append(LINE_FEED);
5251
writer.append(value).append(LINE_FEED);
5352
writer.flush();
@@ -65,8 +64,8 @@ public void addSubtree(Path parentPath, NamedStreamable dir) throws IOException
6564
}
6665

6766
public void addDirectoryPart(Path path) {
68-
writer.append("--" + boundary).append(LINE_FEED);
69-
writer.append("Content-Disposition: file; filename=\"" + encode(path.toString()) + "\"").append(LINE_FEED);
67+
writer.append("--").append(boundary).append(LINE_FEED);
68+
writer.append("Content-Disposition: file; filename=\"").append(encode(path.toString())).append("\"").append(LINE_FEED);
7069
writer.append("Content-Type: application/x-directory").append(LINE_FEED);
7170
writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED);
7271
writer.append(LINE_FEED);
@@ -84,11 +83,11 @@ private static String encode(String in) {
8483

8584
public void addFilePart(String fieldName, Path parent, NamedStreamable uploadFile) {
8685
Optional<String> fileName = uploadFile.getName().map(n -> encode(parent.resolve(n).toString()));
87-
writer.append("--" + boundary).append(LINE_FEED);
86+
writer.append("--").append(boundary).append(LINE_FEED);
8887
if (!fileName.isPresent())
89-
writer.append("Content-Disposition: file; name=\"" + fieldName + "\";").append(LINE_FEED);
88+
writer.append("Content-Disposition: file; name=\"").append(fieldName).append("\";").append(LINE_FEED);
9089
else
91-
writer.append("Content-Disposition: file; filename=\"" + fileName.get() + "\";").append(LINE_FEED);
90+
writer.append("Content-Disposition: file; filename=\"").append(fileName.get()).append("\";").append(LINE_FEED);
9291
writer.append("Content-Type: application/octet-stream").append(LINE_FEED);
9392
writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED);
9493
writer.append(LINE_FEED);

0 commit comments

Comments
 (0)