mailslurp.api.AttachmentControllerApi

Load the API package

import 'package:mailslurp/api.dart';

All URIs are relative to https://api.mailslurp.com

MethodHTTP requestDescription
deleteAttachmentDELETE /attachments/{attachmentId}Delete an attachment
downloadAttachmentAsBase64EncodedGET /attachments/{attachmentId}/base64Get email attachment as base64 encoded string as alternative to binary responses. To read the content decode the Base64 encoded contents.
downloadAttachmentAsBytesGET /attachments/{attachmentId}/bytesDownload attachments. Get email attachment bytes. If you have trouble with byte responses try the downloadAttachmentBase64 response endpoints.
getAttachmentInfoGET /attachments/{attachmentId}/metadataGet email attachment metadata information
getAttachmentsGET /attachmentsGet email attachments
uploadAttachmentPOST /attachmentsUpload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.
uploadAttachmentBytesPOST /attachments/bytesUpload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment.
uploadMultipartFormPOST /attachments/multipartUpload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.

deleteAttachment

deleteAttachment(attachmentId)

Delete an attachment

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

Example

import 'package:mailslurp/api.dart';
// TODO Configure API key authorization: API_KEY
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKeyPrefix = 'Bearer';

final api_instance = AttachmentControllerApi();
final attachmentId = attachmentId_example; // String | ID of attachment

try { 
    api_instance.deleteAttachment(attachmentId);
} catch (e) {
    print('Exception when calling AttachmentControllerApi->deleteAttachment: $en');
}

Parameters

NameTypeDescriptionNotes
attachmentIdStringID of attachment

Return type

void (empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to ]

downloadAttachmentAsBase64Encoded

DownloadAttachmentDto downloadAttachmentAsBase64Encoded(attachmentId)

Get email attachment as base64 encoded string as alternative to binary responses. To read the content decode the Base64 encoded contents.

Returns the specified attachment for a given email as a base 64 encoded string. The response type is application/json. This method is similar to the downloadAttachment method but allows some clients to get around issues with binary responses.

Example

import 'package:mailslurp/api.dart';
// TODO Configure API key authorization: API_KEY
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKeyPrefix = 'Bearer';

final api_instance = AttachmentControllerApi();
final attachmentId = attachmentId_example; // String | ID of attachment

try { 
    final result = api_instance.downloadAttachmentAsBase64Encoded(attachmentId);
    print(result);
} catch (e) {
    print('Exception when calling AttachmentControllerApi->downloadAttachmentAsBase64Encoded: $en');
}

Parameters

NameTypeDescriptionNotes
attachmentIdStringID of attachment

Return type

DownloadAttachmentDto

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to ]

downloadAttachmentAsBytes

String downloadAttachmentAsBytes(attachmentId)

Download attachments. Get email attachment bytes. If you have trouble with byte responses try the downloadAttachmentBase64 response endpoints.

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.

Example

import 'package:mailslurp/api.dart';
// TODO Configure API key authorization: API_KEY
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKeyPrefix = 'Bearer';

final api_instance = AttachmentControllerApi();
final attachmentId = attachmentId_example; // String | ID of attachment

try { 
    final result = api_instance.downloadAttachmentAsBytes(attachmentId);
    print(result);
} catch (e) {
    print('Exception when calling AttachmentControllerApi->downloadAttachmentAsBytes: $en');
}

Parameters

NameTypeDescriptionNotes
attachmentIdStringID of attachment

Return type

String

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/octet-stream

[Back to top] [Back to API list] [Back to Model list] [Back to ]

getAttachmentInfo

AttachmentMetaData getAttachmentInfo(attachmentId)

Get email attachment metadata information

Returns the metadata for an attachment. It is saved separately to the content of the attachment. Contains properties name and content-type and content-length in bytes for a given attachment.

Example

import 'package:mailslurp/api.dart';
// TODO Configure API key authorization: API_KEY
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKeyPrefix = 'Bearer';

final api_instance = AttachmentControllerApi();
final attachmentId = attachmentId_example; // String | ID of attachment

try { 
    final result = api_instance.getAttachmentInfo(attachmentId);
    print(result);
} catch (e) {
    print('Exception when calling AttachmentControllerApi->getAttachmentInfo: $en');
}

Parameters

NameTypeDescriptionNotes
attachmentIdStringID of attachment

Return type

AttachmentMetaData

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to ]

getAttachments

PageAttachmentEntity getAttachments(fileNameFilter, page, size, sort)

Get email attachments

Get all attachments in paginated response. Each entity contains meta data for the attachment such as name and content-type. Use the attachmentId and the download endpoints to get the file contents.

Example

import 'package:mailslurp/api.dart';
// TODO Configure API key authorization: API_KEY
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKeyPrefix = 'Bearer';

final api_instance = AttachmentControllerApi();
final fileNameFilter = fileNameFilter_example; // String | Optional file name and content type search filter
final page = 56; // int | Optional page  event list pagination
final size = 56; // int | Optional page size event list pagination
final sort = sort_example; // String | Optional createdAt sort direction ASC or DESC

try { 
    final result = api_instance.getAttachments(fileNameFilter, page, size, sort);
    print(result);
} catch (e) {
    print('Exception when calling AttachmentControllerApi->getAttachments: $en');
}

Parameters

NameTypeDescriptionNotes
fileNameFilterStringOptional file name and content type search filter[optional]
pageintOptional page event list pagination[optional] [default to 0]
sizeintOptional page size event list pagination[optional] [default to 20]
sortStringOptional createdAt sort direction ASC or DESC[optional] [default to ‘ASC’]

Return type

PageAttachmentEntity

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to ]

uploadAttachment

List uploadAttachment(uploadOptions)

Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

Example

import 'package:mailslurp/api.dart';
// TODO Configure API key authorization: API_KEY
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKeyPrefix = 'Bearer';

final api_instance = AttachmentControllerApi();
final uploadOptions = UploadAttachmentOptions(); // UploadAttachmentOptions | uploadOptions

try { 
    final result = api_instance.uploadAttachment(uploadOptions);
    print(result);
} catch (e) {
    print('Exception when calling AttachmentControllerApi->uploadAttachment: $en');
}

Parameters

NameTypeDescriptionNotes
uploadOptionsUploadAttachmentOptionsuploadOptions

Return type

List

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to ]

uploadAttachmentBytes

List uploadAttachmentBytes(string, filename, byteArray)

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.

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

Example

import 'package:mailslurp/api.dart';
// TODO Configure API key authorization: API_KEY
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKeyPrefix = 'Bearer';

final api_instance = AttachmentControllerApi();
final string = string_example; // String | Optional contentType for file. For instance `application/pdf`
final filename = filename_example; // String | Optional filename to save upload with
final byteArray = String(); // String | Byte array request body

try { 
    final result = api_instance.uploadAttachmentBytes(string, filename, byteArray);
    print(result);
} catch (e) {
    print('Exception when calling AttachmentControllerApi->uploadAttachmentBytes: $en');
}

Parameters

NameTypeDescriptionNotes
stringStringOptional contentType for file. For instance application/pdf[optional]
filenameStringOptional filename to save upload with[optional]
byteArrayStringByte array request body[optional]

Return type

List

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/octet-stream
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to ]

uploadMultipartForm

List uploadMultipartForm(file, contentType, filename, xFilename)

Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

Example

import 'package:mailslurp/api.dart';
// TODO Configure API key authorization: API_KEY
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//defaultApiClient.getAuthentication<ApiKeyAuth>('API_KEY').apiKeyPrefix = 'Bearer';

final api_instance = AttachmentControllerApi();
final file = BINARY_DATA_HERE; // MultipartFile | file
final contentType = contentType_example; // String | Optional content type of attachment
final filename = filename_example; // String | Optional name of file
final xFilename = xFilename_example; // String | Optional content type header of attachment

try { 
    final result = api_instance.uploadMultipartForm(file, contentType, filename, xFilename);
    print(result);
} catch (e) {
    print('Exception when calling AttachmentControllerApi->uploadMultipartForm: $en');
}

Parameters

NameTypeDescriptionNotes
fileMultipartFilefile
contentTypeStringOptional content type of attachment[optional]
filenameStringOptional name of file[optional]
xFilenameStringOptional content type header of attachment[optional]

Return type

List

Authorization

API_KEY

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to ]