Introduce overloaded MockPart constructor that accepts the Content-Type
Closes gh-31757
This commit is contained in:
parent
462ef95904
commit
a596c0e226
|
@ -70,6 +70,19 @@ public class MockPart implements Part {
|
||||||
this.headers.setContentDispositionFormData(name, filename);
|
this.headers.setContentDispositionFormData(name, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for a part with a filename, byte[] content and MediaType mediaType.
|
||||||
|
* @see #getHeaders()
|
||||||
|
*/
|
||||||
|
public MockPart(String name, @Nullable String filename, @Nullable byte[] content, @Nullable MediaType mediaType) {
|
||||||
|
Assert.hasLength(name, "'name' must not be empty");
|
||||||
|
this.name = name;
|
||||||
|
this.filename = filename;
|
||||||
|
this.content = (content != null ? content : new byte[0]);
|
||||||
|
this.headers.setContentDispositionFormData(name, filename);
|
||||||
|
this.headers.setContentType(mediaType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
Loading…
Reference in New Issue