downloadMedia method

Future<String> downloadMedia(
  1. String mediaId
)

Download a media item to the device's temp directory.

Returns the local file path.

Implementation

Future<String> downloadMedia(String mediaId) async {
  final media = await getMedia(mediaId);
  if (media.downloadUrl.isEmpty) {
    throw CloudMediaUploadFailedException('No URL for: $mediaId');
  }
  final tempDir = await getTemporaryDirectory();
  final filePath = '${tempDir.path}/${mediaId}_${media.fileName}';
  await _storage.ref(media.storagePath).writeToFile(File(filePath));
  return filePath;
}