Package com.shri.restinpeace.multipart
Class PartValue
java.lang.Object
com.shri.restinpeace.multipart.PartValue
Wraps a
File, byte[], or InputStream with an
explicit file name, for use as a @PartMap entry's value
when the default file name (the entry's key) isn't the one to send. A
plain (unwrapped) String/File/byte[]/
InputStream value is still handled directly - wrapping is opt-in,
only needed to override the file name.
Map<String, Object> parts = new LinkedHashMap<>();
parts.put("caption", "vacation photo");
parts.put("file", PartValue.of(photoBytes, "photo.jpg"));
-
Method Summary
Modifier and TypeMethodDescriptionReturns the file name to send the wrapped value under.getValue()Returns the wrapped part value.static PartValueWraps abyte[]part value with an explicit file name.static PartValueWraps aFilepart value with an explicit file name.static PartValueof(InputStream stream, String fileName) Wraps anInputStreampart value with an explicit file name.
-
Method Details
-
of
Wraps aFilepart value with an explicit file name.- Parameters:
file- the file to sendfileName- the file name to send it under, overriding the file's own name- Returns:
- a
PartValuewrappingfilewithfileName
-
of
Wraps abyte[]part value with an explicit file name.- Parameters:
bytes- the file content to sendfileName- the file name to send it under- Returns:
- a
PartValuewrappingbyteswithfileName
-
of
Wraps anInputStreampart value with an explicit file name.- Parameters:
stream- the file content to sendfileName- the file name to send it under- Returns:
- a
PartValuewrappingstreamwithfileName
-
getValue
Returns the wrapped part value.- Returns:
- the wrapped value
-
getFileName
Returns the file name to send the wrapped value under.- Returns:
- the file name to send the wrapped value under
-