BFF combined with runtime framework provides file upload capabilities, supporting integrated calls and pure function manual calls.
First, create the api/lambda/upload.ts file:
The formData parameter in the interface processing function can access files uploaded from the client side. It is an Object where the keys correspond to the field names used during the upload.
Next, directly import and call the function in src/routes/upload/page.tsx:
Note: The input type must be { formData: FormData } for the upload to succeed.
You can manually upload files using the fetch API, when calling fetch, set the body as FormData type and submit a post request.