0
            var body = new FormData()
            
            body.append('deal', this.deal)
            body.append('checksum', await this.checksum(file))
            body.append('file', file)
            const { data } = await useFetch(`/api/${this.deal}/upload`, {
                method: 'POST',
                headers: { 'X-Token': useToken() },
                body
            })

If i had some non ascii in file name - server decodes it as ISO-8859-1.

Browser sends

Content-Type: multipart/form-data; boundary=----WebKitFormBoundary4Rr7cdF3ADa3y8y8

    ------WebKitFormBoundary4Rr7cdF3ADa3y8y8
    Content-Disposition: form-data; name="deal"
    
    9c500b3f-4bfc-403e-9360-6876eee044d9
    ------WebKitFormBoundary4Rr7cdF3ADa3y8y8
    Content-Disposition: form-data; name="checksum"
    
    219998802D0DF28DEFA2E6D7F8839F8DAC958CD2ADE85C93AD0A276EAFA97D85
    ------WebKitFormBoundary4Rr7cdF3ADa3y8y8
    Content-Disposition: form-data; name="file"; filename="2 - копия.docx.sig"
    Content-Type: application/pgp-signature
    
    
    ------WebKitFormBoundary4Rr7cdF3ADa3y8y8-- 

How to set charset?

Luuk
  • 12,245
  • 5
  • 22
  • 33
eri
  • 3,133
  • 1
  • 23
  • 35
  • Read this: "HTTP 1.1 says that the default charset is ISO-8859-1 But ....." (https://www.w3.org/International/articles/http-charset/index#charset) – Luuk Jul 18 '23 at 15:18
  • I think I can fix it on server, but chrome browser sends filename in utf and not set charset – eri Jul 18 '23 at 15:53
  • Chrome (browser) should to what the (web-)app is asking it to do, and should not do anything on it's own.. – Luuk Jul 18 '23 at 15:58
  • but it sends filename as utf8 and not tell server that – eri Jul 18 '23 at 20:25
  • You should then read it as utf8, when yor server sends us as such – Luuk Jul 19 '23 at 20:52
  • RFC tells server to read it as ISO-8859-1 – eri Jul 19 '23 at 21:36
  • I do not know anything about your server (and/or it's config), and I would read it in a charset which makes the data correct (despite anything that an RFC has to sa about what should be done) – Luuk Jul 20 '23 at 05:09
  • It was `nodejs`/`nuxt3`/`mutler` stack. – eri Jul 20 '23 at 06:19
  • Please specify the Content-Type. and charset which will be used in your server config, see: https://stackoverflow.com/questions/17872789/node-js-express-how-do-i-set-response-character-encoding#comment46643919_17877151 – Luuk Jul 21 '23 at 06:14

0 Answers0