Vizel API / core/src / VizelImageFileHandlerOptions
Interface: VizelImageFileHandlerOptions
Defined in: packages/core/src/extensions/file-handler.ts:204
Create file handler handlers for image upload integration.
This is a convenience function that creates onPaste and onDrop handlers that integrate with the image upload system.
Example
ts
const { onPaste, onDrop } = createVizelImageFileHandlers({
onUpload: async (file) => {
const formData = new FormData();
formData.append("file", file);
const res = await fetch("/api/upload", { method: "POST", body: formData });
return (await res.json()).url;
},
onError: (error) => console.error(error),
});
const extension = createVizelFileHandlerExtension({ onPaste, onDrop });Properties
onUpload
ts
onUpload: (file) => Promise<string>;Defined in: packages/core/src/extensions/file-handler.ts:208
Upload function that receives a file and returns a URL
Parameters
| Parameter | Type |
|---|---|
file | File |
Returns
Promise<string>
onUploadError?
ts
optional onUploadError?: (error, file) => void;Defined in: packages/core/src/extensions/file-handler.ts:213
Called when an upload error occurs
Parameters
| Parameter | Type |
|---|---|
error | Error |
file | File |
Returns
void
onUploadProgress?
ts
optional onUploadProgress?: (progress, file) => void;Defined in: packages/core/src/extensions/file-handler.ts:218
Called during upload progress (if supported)
Parameters
| Parameter | Type |
|---|---|
progress | number |
file | File |
Returns
void