downloadAttachmentWithHttpInfo method

Future<Response> downloadAttachmentWithHttpInfo(
  1. String emailId,
  2. String attachmentId, {
  3. String? apiKey,
})

Get email attachment bytes. Returned as octet-stream with content type header. If you have trouble with byte responses try the downloadAttachmentBase64 response endpoints and convert the base 64 encoded content to a file or string.

Returns the specified attachment for a given email as a stream / array of bytes. You can find attachment ids in email responses endpoint responses. The response type is application/octet-stream.

Note: This method returns the HTTP Response.

Parameters:

  • String emailId (required): ID of email

  • String attachmentId (required): ID of attachment

  • String apiKey: Can pass apiKey in url for this request if you wish to download the file in a browser. Content type will be set to original content type of the attachment file. This is so that browsers can download the file correctly.

Implementation

Future<Response> downloadAttachmentWithHttpInfo(String emailId, String attachmentId, { String? apiKey, }) async {
  // ignore: prefer_const_declarations
  final path = r'/emails/{emailId}/attachments/{attachmentId}'
    .replaceAll('{emailId}', emailId)
    .replaceAll('{attachmentId}', attachmentId);

  // ignore: prefer_final_locals
  Object? postBody;

  final queryParams = <QueryParam>[];
  final headerParams = <String, String>{};
  final formParams = <String, String>{};

  if (apiKey != null) {
    queryParams.addAll(_queryParams('', 'apiKey', apiKey));
  }

  const contentTypes = <String>[];


  return apiClient.invokeAPI(
    path,
    'GET',
    queryParams,
    postBody,
    headerParams,
    formParams,
    contentTypes.isEmpty ? null : contentTypes.first,
  );
}