io library

File helpers of firebase_storage_dart for platforms with dart:io (not the web).

import 'dart:io';

import 'package:firebase_storage_dart/firebase_storage_dart.dart';
import 'package:firebase_storage_dart/io.dart';

Future<void> backup(FirebaseStorage storage) async {
  final Reference ref = storage.ref('backups/db.sqlite');
  await ref.putFile(File('db.sqlite')).result;
  final int bytes = await ref.writeToFile(File('restored.sqlite'));
  print('restored $bytes bytes');
}

Future<void> fetchVideo(FirebaseStorage storage) async {
  final DownloadTask task = storage.ref('videos/clip.mp4').startDownloadToFile(File('clip.mp4'));
  task.progress.listen((DownloadProgress p) => print('${p.bytesTransferred}/${p.totalBytes}'));
  await task.result;
}

Classes

DownloadProgress
A snapshot of a DownloadTask, as emitted by DownloadTask.progress.
DownloadTask
A download of an object into a file that can be paused, resumed and canceled, and reports its progress. It starts when it is created (by startDownloadToFile of package:firebase_storage_dart/io.dart); await result for the metadata of the object.

Enums

DownloadState
The state of a DownloadTask.

Extensions

ReferenceIo on Reference
Uploads from and downloads to files.