File handling utilities for Mixcore SDK. Provides services for file uploads, downloads and management.
- File upload/download operations
- File metadata handling
- Progress tracking
- TypeScript types for file operations
- Framework-agnostic implementation
- Secure configuration injection
npm install @mixcore/file
# or
pnpm add @mixcore/fileimport { FileServices } from '@mixcore/file';
import { ApiService } from '@mixcore/api';
const fileService = new FileServices({
api: new ApiService({
apiBaseUrl: process.env.MIXCORE_API_URL, // Never hardcode URLs!
apiKey: process.env.MIXCORE_API_KEY // Never hardcode secrets!
})
});
// Upload a file
await fileService.uploadFile(file, {
onProgress: (progress) => console.log(`Uploaded ${progress}%`)
});- Never hardcode API endpoints or credentials
- Always inject configuration at runtime
- Validate file types and sizes before processing
- Use environment variables for sensitive values
| Method | Parameters | Returns | Description |
|---|---|---|---|
| uploadFile | file: File, options?: UploadOptions |
Promise<FileUploadResult> |
Uploads file with progress tracking |
| downloadFile | id: string |
Promise<Blob> |
Downloads file by ID |
| getFileMetadata | id: string |
Promise<FileMetadata> |
Gets file metadata |
| deleteFile | id: string |
Promise<void> |
Deletes file |
Test coverage reports are generated in coverage/ directory when running:
pnpm testSee test files in tests/ directory for implementation details.
This package works with all JavaScript frameworks. See the main README for framework-specific integration examples.
// Example: Using with Vue
import { FileServices } from '@mixcore/file';
import { ApiService } from '@mixcore/api';
const fileService = new FileServices({
api: new ApiService({
apiBaseUrl: import.meta.env.VITE_API_URL,
apiKey: import.meta.env.VITE_API_KEY
})
});
// Upload file in Vue component
const upload = async (file) => {
await fileService.uploadFile(file);
};- @mixcore/api: API client foundation
- @mixcore/database: Database services
Mixcore Community License (MCL). See LICENSE for details.