getFilePreview method

Future<Response> getFilePreview({
  1. required String fileId,
  2. int? width,
  3. int? height,
  4. int? quality,
  5. int? borderWidth,
  6. String? borderColor,
  7. int? borderRadius,
  8. double? opacity,
  9. int? rotation,
  10. String? background,
  11. String? output,
})

Get File Preview

Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image.

Implementation

Future<req.Response> getFilePreview(
    {required String fileId,
    int? width,
    int? height,
    int? quality,
    int? borderWidth,
    String? borderColor,
    int? borderRadius,
    double? opacity,
    int? rotation,
    String? background,
    String? output}) {
  final String path = '/storage/files/{fileId}/preview'
      .replaceAll(RegExp('{fileId}'), fileId);

  final Map<String, dynamic> params = {
    'width': width,
    'height': height,
    'quality': quality,
    'borderWidth': borderWidth,
    'borderColor': borderColor,
    'borderRadius': borderRadius,
    'opacity': opacity,
    'rotation': rotation,
    'background': background,
    'output': output,
    'project': client.config['project'],
  };

  params.keys.forEach((key) {
    if (params[key] is int || params[key] is double) {
      params[key] = params[key].toString();
    }
  });

  return client.call(HttpMethod.get,
      path: path, params: params, responseType: dio.ResponseType.bytes);
}