2

Uploading a file in Angular with the following code

const formData: FormData = new FormData();
formData.append('file', file, 'NameToBeEncoded % ÄÖÜ.pdf');
this.http.request(new HttpRequest('POST', url, formData)).subscribe();

leads to a request with the following:

Content-Disposition: form-data; name="file"; filename="NameToBeEncoded % ÄÖÜ.pdf"

instead of something like this:

Content-Disposition: form-data; name="file"; filename*=UTF-8''NameToBeEncoded%20%25%20%C3%84%C3%96%C3%9C.pdf

RFC2183 states for filename:

Parameter values longer than 78 characters, or which contain non-ASCII characters, MUST be encoded as specified in RFC 2184.

and RFC6266

"filename*" uses the encoding defined in [RFC5987], allowing the use of characters not present in the ISO-8859-1 character set

is there any way to use FormData.append and get the right Content-Disposition filename encoding?

0 Answers0