formdata
formdata copied to clipboard
Specifying a different filename; Not storing the ContentDisposition header.
Currently there are two places where name exists within the files array: (1) the first string in the pair, and (2) the name in the ContentDisposition header. filename OTOH is only in the ContentDisposition header (and thus more difficult to access for readers).
Additionally, when writing out a FormData, the filename for a FilePart is taken from the path of that part. But the consumer of the library might want to specify a different filename than the actual one on disk.
I suggest fixing these problems in the following way:
- Store a
filenamein theFilePart(this change is required inmime-multipart) - Consider the first string in the pair the canonical name, and the
FilePart.filenamethe canonical filename. - When reading, interpret and strip out the ContentDisposition header. When writing, ignore any ContentDisposition header and instead compose one from the canonical data.