Creates a new MultipartFile from a string.
The encoding to use when translating value
into bytes is taken from
contentType
if it has a charset set. Otherwise, it defaults to UTF-8.
contentType
currently defaults to text/plain; charset=utf-8
, but in
the future may be inferred from filename
.
Source
factory MultipartFile.fromString(String field, String value, {String filename, MediaType contentType}) { contentType = contentType == null ? new MediaType("text", "plain") : contentType; Encoding encoding = encodingForCharset(contentType.parameters['charset'], UTF8); contentType = contentType.change(parameters: <String, String>{'charset': encoding.name}); return new MultipartFile.fromBytes(field, encoding.encode(value), filename: filename, contentType: contentType); }