0.1.0 • Published 4 months ago
fileupload-plugin-xnode v0.1.0
fileupload-plugin
A Capacitor plugin for importing and processing files from Android and iOS devices.
Features
- Import files from Android and iOS devices.
- Convert files to base64 format.
- Retrieve file metadata such as size, type, and name.
- Asynchronous processing for better performance.
Installation
Install the plugin using npm:
npm install fileupload-plugin
npx cap sync
API
processFile(...)
processFile(options: { filePath: string; type: string; name: string; }) => Promise<{ base64: string; size: number; type: string; fileName: string; byteArray: Uint8Array; }>
Parameters
Param | Type | Description |
---|---|---|
options | { filePath: string; type: string; name: string; } | File processing options. |
Returns
A promise resolving to:
{
base64: string;
size: number;
type: string;
fileName: string;
byteArray: Uint8Array;
}
Usage
Import and use the plugin in your code:
import { Plugins } from '@capacitor/core';
const { FileuploadPlugin } = Plugins;
async function uploadFile() {
const result = await FileuploadPlugin.processFile({
filePath: 'path/to/file',
type: 'image/png',
name: 'example.png'
});
console.log('Base64:', result.base64);
console.log('File Size:', result.size);
}
License
MIT License