Skip to content

Commit 3234e09

Browse files
committed
Create default implementation of String variant of addFilePart
1 parent 9f2d2d4 commit 3234e09

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sources/net.sf.j2s.java.core/src/javajs/http/HttpClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package javajs.http;
22

3+
import java.io.ByteArrayInputStream;
34
import java.io.Closeable;
45
import java.io.File;
56
import java.io.IOException;
@@ -88,7 +89,10 @@ public interface HttpRequest {
8889
* @param fileName server-side fileName to associate with this file
8990
* @return
9091
*/
91-
public HttpRequest addFilePart(String name, String data, String contentType, String fileName);
92+
public default HttpRequest addFilePart(String name, String data, String contentType, String fileName) {
93+
var stream = new ByteArrayInputStream(data.getBytes());
94+
return addFilePart(name, stream, contentType, fileName);
95+
}
9296

9397
/**
9498
* Add a file-type multipart/form-data derived from a File object, using

0 commit comments

Comments
 (0)