File Uploader

The uploadFile function can be used to open a file uploader dialog. It supports the following features:

  • Upload from local device
  • Paste images from clipboard
  • Upload by URL
  • Upload by drag and drop

Usage

import { uploadFile } from '@hyvor/design/components';

async function handleUpload() {
	const file = await uploadFile({
		type: 'image', // 'audio'
		uploader: async (blob, name) => {
			// upload the blob to your server
			// return an object with a .url property

			return {
				url: 'https://example.com/path/to/uploaded/image.jpg'
			};
		}
	});
	
	if (file) {
		console.log('Uploaded file URL:', file.url);
	} else {
		console.log('Upload cancelled');
	}
}