getDeploymentDownload method

Future<Uint8List> getDeploymentDownload({
  1. required String functionId,
  2. required String deploymentId,
  3. DeploymentDownloadType? type,
})

Get a function deployment 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> getDeploymentDownload({
  required String functionId,
  required String deploymentId,
  enums.DeploymentDownloadType? type,
}) async {
  final String apiPath =
      '/functions/{functionId}/deployments/{deploymentId}/download'
          .replaceAll('{functionId}', functionId)
          .replaceAll('{deploymentId}', deploymentId);

  final Map<String, dynamic> params = {
    'type': type?.value,

    'project': client.config['project'],
    'key': client.config['key'],
  };

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