Improved Part support in MultipartBodyBuilder

1. Add contentType and filename options to PartBuilder.

2. Revert recently committed #44659f since asyncPart can't properly
support Publisher of Part (only Mono, can't support filename), and
replace that with support for Part in the regular part method.

Closes gh-23083
This commit is contained in:
Rossen Stoyanchev
2019-06-04 17:21:39 -04:00
parent 8781c01edf
commit 69eba32284
3 changed files with 72 additions and 28 deletions

View File

@@ -414,8 +414,9 @@ multipart request. The following example shows how to create a `MultiValueMap<St
----
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.part("fieldPart", "fieldValue");
builder.part("filePart", new FileSystemResource("...logo.png"));
builder.part("filePart1", new FileSystemResource("...logo.png"));
builder.part("jsonPart", new Person("Jason"));
builder.part("myPart", part); // Part from a server request
MultiValueMap<String, HttpEntity<?>> parts = builder.build();
----