uploadAttachmentBytes method

Future<List<String>?> uploadAttachmentBytes(
  1. UploadAttachmentBytesRequest uploadAttachmentBytesRequest, {
  2. String? contentType,
  3. String? filename,
})

Upload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment.

Parameters:

  • UploadAttachmentBytesRequest uploadAttachmentBytesRequest (required):

  • String contentType: Optional contentType for file. For instance application/pdf

  • String filename: Optional filename to save upload with

Implementation

Future<List<String>?> uploadAttachmentBytes(UploadAttachmentBytesRequest uploadAttachmentBytesRequest, { String? contentType, String? filename, }) async {
  final response = await uploadAttachmentBytesWithHttpInfo(uploadAttachmentBytesRequest,  contentType: contentType, filename: filename, );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    final responseBody = await _decodeBodyBytes(response);
    return (await apiClient.deserializeAsync(responseBody, 'List<String>') as List)
      .cast<String>()
      .toList();

  }
  return null;
}