@thangved/pick-files
v1.0.10
Published
A simple and efficient file picker library for web applications
Readme
@thangved/pick-files
A simple and efficient file picker library for web applications.
Features
- [x] Supports multiple file selection.
- [x] Customizable file types
- [x] Customizable file size limits
- [x] Easy to integrate and use.
- [ ] Validation file types
Installation
You can install the package via npm:
npm install @thangved/pick-filesOr via yarn:
yarn add @thangved/pick-filesUsage
Here's a basic example of how to use the @thangved/pick-files library in your project:
import { pickFiles } from '@thangved/pick-files';
const handleFileSelection = async () => {
try {
const { files } = await pickFiles({
multiple: true,
accept: '*', // Accept all file types
//Or specify file types
// accept: ['image/*', '.pdf', '.docx'],
maxSize: 5 * 1024 * 1024, // 5MB
});
console.log('Selected files:', files);
} catch (error) {
console.error('File selection error:', error);
}
};API
pickFiles(options): Promise<{ files: File[] }>
options(Object): Configuration options for file selection.multiple(Boolean): Allow multiple file selection. Default isfalse.accept(String): Comma-separated list of accepted file types. Default is'*'.
Returns: A promise that resolves to an object containing the selected files.
License
MIT License. See the LICENSE file for details.
