Converting a Browser File to Effect Multipart.PersistedFile for Large Uploads

How do I convert a Browser File to a Effect Multipart.PersistedFile? I use the HttpApiClient and my endpoint definition looks like this:

const PdfApis = HttpApiGroup.make('PdfApis').add(
  HttpApiEndpoint.post('upload')`/`
    .setPayload(
      HttpApiSchema.Multipart(
        Schema.Struct({ file: Multipart.SingleFileSchema }),
        { maxFieldSize: 100 * 1024 * 1024 * 1024 }
      )
    )
    .addSuccess(Schema.String)
);


In the frontend I use the HttpApiClient to make the request.

const formData = new FormData();
formData.append('file', file); // file is of type File
return client.PdfApis.upload({ payload: formData });


But now i get this schema error when calling the endpoint. But only when I call it with a big file.... So i think i should convert the File to a PersistedFile?:
message: "{ readonly file: (itemsCount(1) <-> PersistedFile) }\n└─ [\"file\"]\n   └─ is missing"
_tag: "HttpApiDecodeError"
Was this page helpful?