getFileDownload method

Future<Uint8List> getFileDownload({
  1. required String bucketId,
  2. required String fileId,
})

Get file for download

Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.

Implementation

Future<Uint8List> getFileDownload(
    {required String bucketId, required String fileId}) async {
  final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'
      .replaceAll('{bucketId}', bucketId)
      .replaceAll('{fileId}', fileId);

  final Map<String, dynamic> params = {
    'project': client.config['project'],
    'session': client.config['session'],
  };

  final res = await client.call(HttpMethod.get,
      path: apiPath, params: params, responseType: ResponseType.bytes);
  return res.data;
}