Effect CommunityEC
Effect Community14mo ago
26 replies
Orlein

Issue with Multipart.FilesSchema and Non-ASCII Filenames in Swagger Uploads

import { HttpApiSchema, Multipart } from "@effect/platform"

class UsersApi extends HttpApiGroup.make("users").add(
  HttpApiEndpoint.post("upload", "/users/upload").setPayload(
    HttpApiSchema.Multipart(
      Schema.Struct({
        // add a "files" field to the schema
        files: Multipart.FilesSchema
      })
    )
  )
) {}

From this example code, I got an error from Multipart.FilesSchema . If the filename contains non-ASCII characters, the key become empty. As I'm Korean, I've tried to upload any file named '.png', the error message keep showing me path: ["files"], message: is missing. When I change the filename into 'puppy.png' (which has same meaning), it works well.
Fortunately, it works very well with <form /> tag. It encodes the Korean characters into the UTF-8 encoding.
I spent about 7 hours for this, so I'm leaving this message who tries to upload a non-ASCII files from swagger.
Was this page helpful?