# mailslurp_client.AttachmentControllerApi
All URIs are relative to https://api.mailslurp.com
Method | HTTP request | Description |
---|---|---|
upload_attachment | POST /attachments | Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment. |
upload_attachment_bytes | POST /attachments/bytes | 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. |
upload_multipart_form | POST /attachments/multipart | Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment. |
# upload_attachment
list[str] upload_attachment(upload_options)
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
- Api Key Authentication (API_KEY):
from __future__ import print_function
import time
import mailslurp_client
from mailslurp_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.mailslurp.com
# See configuration.py for a list of all supported configuration parameters.
configuration = mailslurp_client.Configuration(
host = "https://api.mailslurp.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: API_KEY
configuration = mailslurp_client.Configuration(
host = "https://api.mailslurp.com",
api_key = {
'x-api-key': 'YOUR_API_KEY'
}
)
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-api-key'] = 'Bearer'
# Enter a context with an instance of the API client
with mailslurp_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = mailslurp_client.AttachmentControllerApi(api_client)
upload_options = mailslurp_client.UploadAttachmentOptions() # UploadAttachmentOptions | uploadOptions
try:
# Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.
api_response = api_instance.upload_attachment(upload_options)
pprint(api_response)
except ApiException as e:
print("Exception when calling AttachmentControllerApi->upload_attachment: %s\n" % e)
# Parameters
Name | Type | Description | Notes |
---|---|---|---|
upload_options | UploadAttachmentOptions | uploadOptions |
# Return type
list[str]
# Authorization
# HTTP request headers
- Content-Type: application/json
- Accept: application/json
# HTTP response details
Status code | Description | Response headers |
---|---|---|
201 | Created | - |
401 | Unauthorized | - |
403 | Forbidden | - |
404 | Not Found | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
# upload_attachment_bytes
list[str] upload_attachment_bytes(string=string, filename=filename, byte_array=byte_array)
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
- Api Key Authentication (API_KEY):
from __future__ import print_function
import time
import mailslurp_client
from mailslurp_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.mailslurp.com
# See configuration.py for a list of all supported configuration parameters.
configuration = mailslurp_client.Configuration(
host = "https://api.mailslurp.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: API_KEY
configuration = mailslurp_client.Configuration(
host = "https://api.mailslurp.com",
api_key = {
'x-api-key': 'YOUR_API_KEY'
}
)
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-api-key'] = 'Bearer'
# Enter a context with an instance of the API client
with mailslurp_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = mailslurp_client.AttachmentControllerApi(api_client)
string = 'string_example' # str | Optional contentType for file. For instance `application/pdf` (optional)
filename = 'filename_example' # str | Optional filename to save upload with (optional)
byte_array = 'byte_array_example' # str | Byte array request body (optional)
try:
# 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.
api_response = api_instance.upload_attachment_bytes(string=string, filename=filename, byte_array=byte_array)
pprint(api_response)
except ApiException as e:
print("Exception when calling AttachmentControllerApi->upload_attachment_bytes: %s\n" % e)
# Parameters
Name | Type | Description | Notes |
---|---|---|---|
string | str | Optional contentType for file. For instance `application/pdf` | [optional] |
filename | str | Optional filename to save upload with | [optional] |
byte_array | str | Byte array request body | [optional] |
# Return type
list[str]
# Authorization
# HTTP request headers
- Content-Type: application/octet-stream
- Accept: application/json
# HTTP response details
Status code | Description | Response headers |
---|---|---|
201 | Created | - |
401 | Unauthorized | - |
403 | Forbidden | - |
404 | Not Found | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
# upload_multipart_form
list[str] upload_multipart_form(file, content_type=content_type, filename=filename, x_filename=x_filename)
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
- Api Key Authentication (API_KEY):
from __future__ import print_function
import time
import mailslurp_client
from mailslurp_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.mailslurp.com
# See configuration.py for a list of all supported configuration parameters.
configuration = mailslurp_client.Configuration(
host = "https://api.mailslurp.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: API_KEY
configuration = mailslurp_client.Configuration(
host = "https://api.mailslurp.com",
api_key = {
'x-api-key': 'YOUR_API_KEY'
}
)
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-api-key'] = 'Bearer'
# Enter a context with an instance of the API client
with mailslurp_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = mailslurp_client.AttachmentControllerApi(api_client)
file = '/path/to/file' # file | file
content_type = 'content_type_example' # str | Optional content type of attachment (optional)
filename = 'filename_example' # str | Optional name of file (optional)
x_filename = 'x_filename_example' # str | Optional content type header of attachment (optional)
try:
# Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.
api_response = api_instance.upload_multipart_form(file, content_type=content_type, filename=filename, x_filename=x_filename)
pprint(api_response)
except ApiException as e:
print("Exception when calling AttachmentControllerApi->upload_multipart_form: %s\n" % e)
# Parameters
Name | Type | Description | Notes |
---|---|---|---|
file | file | file | |
content_type | str | Optional content type of attachment | [optional] |
filename | str | Optional name of file | [optional] |
x_filename | str | Optional content type header of attachment | [optional] |
# Return type
list[str]
# Authorization
# HTTP request headers
- Content-Type: multipart/form-data
- Accept: application/json
# HTTP response details
Status code | Description | Response headers |
---|---|---|
201 | Created | - |
401 | Unauthorized | - |
403 | Forbidden | - |
404 | Not Found | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]