getPreview method

Get a preview by file path.

Returns a Future containing a DynamiteResponse with the status code, deserialized body and headers. Throws a DynamiteApiException if the API call does not return an expected status code.

Parameters:

  • file Path of the file. Defaults to "".
  • x Width of the preview. A width of -1 will use the original image width. Defaults to 32.
  • y Height of the preview. A height of -1 will use the original image height. Defaults to 32.
  • a Preserve the aspect ratio. Defaults to 0.
  • forceIcon Force returning an icon. Defaults to 1.
  • mode How to crop the image. Defaults to "fill".
  • mimeFallback Whether to fallback to the mime icon if no preview is available. Defaults to 0.

Status codes:

  • 200: Preview returned
  • 400: Getting preview is not possible
  • 403: Getting preview is not allowed
  • 404: Preview not found
  • 303: Redirect to the mime icon url if mimeFallback is true

See:

Implementation

Future<_i1.DynamiteResponse<Uint8List, void>> getPreview({
  String? file,
  int? x,
  int? y,
  PreviewGetPreviewA? a,
  PreviewGetPreviewForceIcon? forceIcon,
  PreviewGetPreviewMode? mode,
  PreviewGetPreviewMimeFallback? mimeFallback,
}) async {
  final _request = $getPreview_Request(
    file: file,
    x: x,
    y: y,
    a: a,
    forceIcon: forceIcon,
    mode: mode,
    mimeFallback: mimeFallback,
  );
  final _streamedResponse = await _rootClient.httpClient.send(_request);
  final _response = await _i3.Response.fromStream(_streamedResponse);

  final _serializer = $getPreview_Serializer();
  return _i1.ResponseConverter<Uint8List, void>(_serializer).convert(_response);
}