uploadFile method

  1. @override
Future<String> uploadFile(
  1. String localFilePath,
  2. String remoteFilePath
)
override

Implementation

@override
Future<String> uploadFile(
  String localFilePath,
  String remoteFilePath,
) async {
  try {
    final file = File(localFilePath);
    final data = await file.readAsBytes();
    final ref = _storage.ref(remoteFilePath);
    final uploadTask = ref.putData(data);
    final snapshot = await uploadTask;
    final downloadUrl = await snapshot.ref.getDownloadURL();
    return downloadUrl;
  } catch (e) {
    debugPrint(
        'Error uploading file from [$localFilePath] to [$remoteFilePath] due to [$e]');
    rethrow;
  }
}