download method

Future<Uint8List> download(
  1. String path, {
  2. TransformOptions? transform,
})

Downloads a file.

path is the file path to be downloaded, including the path and file name. For example download('folder/image.png').

transform download a transformed variant of the image with the provided options

Implementation

Future<Uint8List> download(String path, {TransformOptions? transform}) async {
  final wantsTransformations = transform != null;
  final finalPath = _getFinalPath(path);
  final renderPath =
      wantsTransformations ? 'render/image/authenticated' : 'object';
  final queryParams = transform?.toQueryParams;
  final options = FetchOptions(headers: headers, noResolveJson: true);

  var fetchUrl = Uri.parse('$url/$renderPath/$finalPath');
  fetchUrl = fetchUrl.replace(queryParameters: queryParams);

  final response =
      await _storageFetch.get(fetchUrl.toString(), options: options);
  return response as Uint8List;
}