BeechCMS / @beechcms/forms-react / fileToAttachment
Function: fileToAttachment()
fileToAttachment(
file):Promise<{attachment:FormFileAttachment;error?:string; }>
Reads a browser File object, verifies its magic bytes signature, and converts it to a FormFileAttachment ready for submission to the BeechCMS Public Form API.
Parameters
file
File
The browser File instance to convert and validate.
Returns
Promise<{ attachment: FormFileAttachment; error?: string; }>
A promise resolving to the attachment payload and any validation error encountered.