Attachments
AttachmentsService ¶
Service for managing UiPath attachments.
Attachments allow you to upload and download files to be used within UiPath processes, actions, and other UiPath services.
Reference: https://docs.uipath.com/orchestrator/reference/api-attachments
delete ¶
Delete an attachment.
This method deletes an attachment from UiPath. If the attachment is not found in UiPath (404 error), it will check for a local file in the temporary directory that matches the UUID.
Note
The local file fallback functionality is intended for local development and debugging purposes only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
UUID
|
The key of the attachment to delete. |
required |
folder_key
|
str | None
|
The key of the folder. Override the default one set in the SDK config. |
None
|
folder_path
|
str | None
|
The path of the folder. Override the default one set in the SDK config. |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
If the deletion fails and no local file is found. |
Examples:
delete_async
async
¶
Delete an attachment asynchronously.
This method asynchronously deletes an attachment from UiPath. If the attachment is not found in UiPath (404 error), it will check for a local file in the temporary directory that matches the UUID.
Note
The local file fallback functionality is intended for local development and debugging purposes only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
UUID
|
The key of the attachment to delete. |
required |
folder_key
|
str | None
|
The key of the folder. Override the default one set in the SDK config. |
None
|
folder_path
|
str | None
|
The path of the folder. Override the default one set in the SDK config. |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
If the deletion fails and no local file is found. |
Examples:
download ¶
Download an attachment.
This method downloads an attachment from UiPath to a local file. If the attachment is not found in UiPath (404 error), it will check for a local file in the temporary directory that matches the UUID.
Note
The local file fallback functionality is intended for local development and debugging purposes only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
UUID
|
The key of the attachment to download. |
required |
destination_path
|
str
|
The local path where the attachment will be saved. |
required |
folder_key
|
str | None
|
The key of the folder. Override the default one set in the SDK config. |
None
|
folder_path
|
str | None
|
The path of the folder. Override the default one set in the SDK config. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the downloaded attachment. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the download fails and no local file is found. |
Examples:
download_async
async
¶
Download an attachment asynchronously.
This method asynchronously downloads an attachment from UiPath to a local file. If the attachment is not found in UiPath (404 error), it will check for a local file in the temporary directory that matches the UUID.
Note
The local file fallback functionality is intended for local development and debugging purposes only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
UUID
|
The key of the attachment to download. |
required |
destination_path
|
str
|
The local path where the attachment will be saved. |
required |
folder_key
|
str | None
|
The key of the folder. Override the default one set in the SDK config. |
None
|
folder_path
|
str | None
|
The path of the folder. Override the default one set in the SDK config. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the downloaded attachment. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the download fails and no local file is found. |
Examples:
open ¶
Open an attachment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attachment
|
Attachment
|
The attachment to open. |
required |
mode
|
AttachmentMode
|
The mode to use. |
READ
|
content
|
RequestContent | None
|
An optional request content to upload. |
None
|
folder_key
|
str | None
|
The key of the folder. Override the default one set in the SDK config. |
None
|
folder_path
|
str | None
|
The path of the folder. Override the default one set in the SDK config. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
Iterator[tuple[Attachment, Response]]
|
The name of the downloaded attachment. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the download fails and no local file is found. |
open_async
async
¶
open_async(
*,
attachment,
mode=AttachmentMode.READ,
content=None,
folder_key=None,
folder_path=None,
)
Open an attachment asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attachment
|
Attachment
|
The attachment to open. |
required |
mode
|
AttachmentMode
|
The mode to use. |
READ
|
content
|
RequestContent
|
An optional request content to upload. |
None
|
folder_key
|
str | None
|
The key of the folder. Override the default one set in the SDK config. |
None
|
folder_path
|
str | None
|
The path of the folder. Override the default one set in the SDK config. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
AsyncIterator[tuple[Attachment, Response]]
|
The name of the downloaded attachment. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the download fails and no local file is found. |
upload ¶
Upload a file or content to UiPath as an attachment.
This method uploads content to UiPath and makes it available as an attachment. You can either provide a file path or content in memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the attachment file. |
required |
content
|
str | bytes | None
|
The content to upload (string or bytes). |
None
|
source_path
|
str | None
|
The local path of the file to upload. |
None
|
folder_key
|
str | None
|
The key of the folder. Override the default one set in the SDK config. |
None
|
folder_path
|
str | None
|
The path of the folder. Override the default one set in the SDK config. |
None
|
Returns:
| Type | Description |
|---|---|
UUID
|
uuid.UUID: The UUID of the created attachment. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither content nor source_path is provided, or if both are provided. |
Exception
|
If the upload fails. |
Examples:
from uipath.platform import UiPath
client = UiPath()
# Upload a file from disk
attachment_key = client.attachments.upload(
name="my-document.pdf",
source_path="path/to/local/document.pdf",
)
print(f"Uploaded attachment with key: {attachment_key}")
# Upload content from memory
attachment_key = client.attachments.upload(
name="notes.txt",
content="This is a text file content",
)
print(f"Uploaded attachment with key: {attachment_key}")
upload_async
async
¶
Upload a file or content to UiPath as an attachment asynchronously.
This method asynchronously uploads content to UiPath and makes it available as an attachment. You can either provide a file path or content in memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the attachment file. |
required |
content
|
str | bytes | None
|
The content to upload (string or bytes). |
None
|
source_path
|
str | None
|
The local path of the file to upload. |
None
|
folder_key
|
str | None
|
The key of the folder. Override the default one set in the SDK config. |
None
|
folder_path
|
str | None
|
The path of the folder. Override the default one set in the SDK config. |
None
|
Returns:
| Type | Description |
|---|---|
UUID
|
uuid.UUID: The UUID of the created attachment. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither content nor source_path is provided, or if both are provided. |
Exception
|
If the upload fails. |
Examples:
import asyncio
from uipath.platform import UiPath
client = UiPath()
async def main():
# Upload a file from disk
attachment_key = await client.attachments.upload_async(
name="my-document.pdf",
source_path="path/to/local/document.pdf",
)
print(f"Uploaded attachment with key: {attachment_key}")
# Upload content from memory
attachment_key = await client.attachments.upload_async(
name="notes.txt",
content="This is a text file content",
)
print(f"Uploaded attachment with key: {attachment_key}")