Files posted with Server Actions in FormData have wrong encoding on file name.
Unanswered
American Crocodile posted this in #help-forum
American CrocodileOP
If the file name includes a non-ascii character this gets incorrectly encoded on the server side.
Client Component gets passed in a Server Action that accepts FormData called onFileUpload
Server action
The
Client Component gets passed in a Server Action that accepts FormData called onFileUpload
const sendFiles = async () => {
const formData = new FormData()
for (let index = 0; index < files.length; index++) {
formData.append(files[index].name, files[index])
}
onFileUpload(formData)
}Server action
'use server'
const files = [] as File[]
formData.forEach((value) => {
value instanceof File && files.push(value)
})The
file.name is not encoded correctly. Is this fixable?