I am using the HttpClient and HttpRequest available on java.net.http. I have successfully sent some GET and POST requests, but I have no clue about how to send a PUT/POST request with multipart/form-data body:
HttpRequest dataRequest = HttpRequest.newBuilder()
.header("accept", "*/*")
.header("Content-Type", "multipart/form-data")
// .POST() ??
.uri(URI.create(DATA_URL)
.build();
The curl equivalent of this request would be something like:
curl -X PUT "https://www.example.com/data" -H "accept: */*" -H "Content-Type: multipart/form-data" -F "file=@audiofile.wav;type=audio/wav"
Should I use some kind of BodyPublishers in the POST() or PUT() method in order to achieve that? Any clue?