Storage — Flutter SDK
Upload bytes
Section titled “Upload bytes”import 'dart:typed_data';
final bytes = Uint8List.fromList([/* ... */]);final file = await bunbase.storage.upload( 'avatars', // bucket name 'photo.jpg', // destination filename bytes, mimeType: 'image/jpeg',);print(file.url);Upload from file (path)
Section titled “Upload from file (path)”import 'dart:io';
final file = File('/path/to/image.jpg');final bytes = await file.readAsBytes();final record = await bunbase.storage.upload('avatars', 'image.jpg', bytes, mimeType: 'image/jpeg');Upload with progress
Section titled “Upload with progress”final record = await bunbase.storage.upload( 'videos', 'clip.mp4', bytes, mimeType: 'video/mp4', onProgress: (double progress) { setState(() => _uploadProgress = progress); // 0.0 → 1.0 },);Extra form fields
Section titled “Extra form fields”Pass additional metadata alongside the file:
await bunbase.storage.upload( 'documents', 'contract.pdf', bytes, mimeType: 'application/pdf', fields: {'folder': 'legal', 'owner': userId},);Download
Section titled “Download”final Uint8List bytes = await bunbase.storage.download('avatars', 'photo.jpg');Delete
Section titled “Delete”await bunbase.storage.delete('avatars', 'photo.jpg');List files
Section titled “List files”final files = await bunbase.storage.list('avatars');
// With prefix filter:final profilePics = await bunbase.storage.list('avatars', prefix: 'users/');Signed URL
Section titled “Signed URL”Generate a short-lived URL for direct client access (default TTL: 1 hour):
final result = await bunbase.storage.getSignedUrl('avatars', 'photo.jpg');print(result.url); // https://cdn.example.com/avatars/photo.jpg?token=...
// Custom TTL:final result = await bunbase.storage.getSignedUrl( 'avatars', 'photo.jpg', ttl: const Duration(minutes: 15),);FileRecord fields
Section titled “FileRecord fields”| Field | Type | Description |
|---|---|---|
id | String | Unique record ID |
bucket | String | Bucket name |
name | String | Filename |
size | int | Size in bytes |
mimeType | String | MIME type |
url | String | Public URL (or signed URL path) |
createdAt | String | ISO-8601 timestamp |