@nexim/upload-sdk
Version:
TypeScript SDK for seamless integration with Nexim Media Upload Service. It provides state machine-based upload handling, progress tracking, and type-safe API for image optimization and file uploads.
36 lines (24 loc) • 1.13 kB
Markdown
[@nexim/upload-sdk](../README.md) / pickAndProcessFile
# Function: pickAndProcessFile()
> **pickAndProcessFile**(`accept`: `string`, `callback`: (`file`: `File`) => `MaybePromise`\<`void`\>): `void`
Creates and triggers a virtual file input element to handle file selection.
This utility creates a temporary file input element, attaches event handlers,
and removes itself after use.
Features:
- Creates a hidden file input element
- Handles file selection through browser's native interface
- Automatically cleans up after selection
- Supports async callbacks
## Parameters
| Parameter | Type | Description |
| ---------- | -------------------------------------------- | ------------------------------------------ |
| `accept` | `string` | Comma-separated list of allowed file types |
| `callback` | (`file`: `File`) => `MaybePromise`\<`void`\> | Function to handle the selected file |
## Returns
`void`
## Example
```ts
pickAndProcessFile('image/*', async (file) => {
await uploadImage(file);
});
```