downloadImage method

Future<Response?> downloadImage(
  1. String filePath, {
  2. String? fileToken,
  3. ImageTransformConfig? imageTransformConfig,
})

Downloads the image at the provided path, transforming it if requested.

The fileToken argument must be provided if the resource is protected by a storage function that checks the file's resource.Metadata.token (https://nhost.github.io/hasura-backend-plus/docs/storage-rules).

imageTransformConfig (optional) instructs the backend to scale or adjust the quality of the returned image.

The file is returned as an HTTP response, populated with the headers.

Implementation

Future<http.Response?> downloadImage(
  String filePath, {
  String? fileToken,
  ImageTransformConfig? imageTransformConfig,
}) {
  return _apiClient.get<http.Response>(
    _objectPath(filePath),
    query: {
      if (fileToken != null) 'token': fileToken,
      ...?imageTransformConfig?.toQueryArguments(),
    },
    headers: _session.authenticationHeaders,
  );
}