# Error: Server Actions cannot receive ArrayBuffer or Blob directly from FormData. Use File objects or convert to base64.

- **ID:** `nextjs/server-action-formdata-arraybuffer`
- **Domain:** nextjs
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A Server Action receives FormData containing ArrayBuffer or Blob entries, which are not directly serializable for server transmission. Next.js Server Actions only support File, string, or number types from FormData.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Next.js 14.x | active | — | — |
| Next.js 15.x | active | — | — |

## Workarounds

1. **Convert ArrayBuffer to base64 on the client before appending to FormData. Example: const base64 = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer))); formData.append('file', base64); Then decode in the Server Action: const buffer = Buffer.from(base64, 'base64');** (80% success)
   ```
   Convert ArrayBuffer to base64 on the client before appending to FormData. Example: const base64 = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer))); formData.append('file', base64); Then decode in the Server Action: const buffer = Buffer.from(base64, 'base64');
   ```
2. **Wrap the ArrayBuffer in a File object before appending to FormData. Example: const file = new File([arrayBuffer], 'filename.bin'); formData.append('file', file); The Server Action will receive it as a File object.** (85% success)
   ```
   Wrap the ArrayBuffer in a File object before appending to FormData. Example: const file = new File([arrayBuffer], 'filename.bin'); formData.append('file', file); The Server Action will receive it as a File object.
   ```
3. **Instead of using a Server Action, send the data via a fetch POST request to an API route that accepts binary data directly.** (75% success)
   ```
   Instead of using a Server Action, send the data via a fetch POST request to an API route that accepts binary data directly.
   ```

## Dead Ends

- **** — ArrayBuffer is binary data; JSON.parse will fail on it unless it is already a JSON string. This approach also does not address the serialization issue for the Server Action. (90% fail)
- **** — FormData serialization does not support ArrayBuffer; it will be converted to a string '[object ArrayBuffer]' or cause a TypeError during submission. (100% fail)
- **** — Next.js Server Actions handle FormData parsing internally before middleware runs. You cannot intercept the request body in middleware for Server Actions. (85% fail)
