|
15 | 15 | from ..._utils._ssl_context import get_httpx_client_kwargs |
16 | 16 | from ..._utils.constants import TEMP_ATTACHMENTS_FOLDER |
17 | 17 | from ...tracing import traced |
18 | | -from ..attachments import Attachment, AttachmentMode |
| 18 | +from ..attachments import Attachment, AttachmentMode, BlobFileAccessInfo |
19 | 19 | from ..common import BaseService, FolderContext, UiPathApiConfig, UiPathExecutionContext |
20 | 20 |
|
21 | 21 |
|
@@ -709,6 +709,124 @@ async def main(): |
709 | 709 |
|
710 | 710 | return attachment_key |
711 | 711 |
|
| 712 | + @traced(name="attachments_get_blob_uri", run_type="uipath") |
| 713 | + def get_blob_file_access_uri( |
| 714 | + self, |
| 715 | + *, |
| 716 | + key: uuid.UUID, |
| 717 | + folder_key: str | None = None, |
| 718 | + folder_path: str | None = None, |
| 719 | + ) -> BlobFileAccessInfo: |
| 720 | + """Get the BlobFileAccess information for an attachment. |
| 721 | +
|
| 722 | + This method retrieves the blob storage URI and filename for downloading |
| 723 | + an attachment without actually downloading the file. |
| 724 | +
|
| 725 | + Args: |
| 726 | + key (uuid.UUID): The key of the attachment. |
| 727 | + folder_key (str | None): The key of the folder. Override the default one set in the SDK config. |
| 728 | + folder_path (str | None): The path of the folder. Override the default one set in the SDK config. |
| 729 | +
|
| 730 | + Returns: |
| 731 | + BlobFileAccessInfo: Object containing the blob storage URI and attachment name. |
| 732 | +
|
| 733 | + Raises: |
| 734 | + Exception: If the attachment is not found or the request fails. |
| 735 | +
|
| 736 | + Examples: |
| 737 | + ```python |
| 738 | + from uipath.platform import UiPath |
| 739 | +
|
| 740 | + client = UiPath() |
| 741 | +
|
| 742 | + info = client.attachments.get_blob_file_access_uri( |
| 743 | + key=uuid.UUID("123e4567-e89b-12d3-a456-426614174000") |
| 744 | + ) |
| 745 | + print(f"Attachment ID: {info.id}") |
| 746 | + print(f"Blob URI: {info.uri}") |
| 747 | + print(f"File name: {info.name}") |
| 748 | + ``` |
| 749 | + """ |
| 750 | + spec = self._retrieve_download_uri_spec( |
| 751 | + key=key, |
| 752 | + folder_key=folder_key, |
| 753 | + folder_path=folder_path, |
| 754 | + ) |
| 755 | + |
| 756 | + result = self.request( |
| 757 | + spec.method, |
| 758 | + url=spec.endpoint, |
| 759 | + params=spec.params, |
| 760 | + headers=spec.headers, |
| 761 | + ).json() |
| 762 | + |
| 763 | + return BlobFileAccessInfo( |
| 764 | + id=key, |
| 765 | + uri=result["BlobFileAccess"]["Uri"], |
| 766 | + name=result["Name"], |
| 767 | + ) |
| 768 | + |
| 769 | + @traced(name="attachments_get_blob_uri", run_type="uipath") |
| 770 | + async def get_blob_file_access_uri_async( |
| 771 | + self, |
| 772 | + *, |
| 773 | + key: uuid.UUID, |
| 774 | + folder_key: str | None = None, |
| 775 | + folder_path: str | None = None, |
| 776 | + ) -> BlobFileAccessInfo: |
| 777 | + """Get the BlobFileAccess information for an attachment asynchronously. |
| 778 | +
|
| 779 | + This method asynchronously retrieves the blob storage URI and filename |
| 780 | + for downloading an attachment without actually downloading the file. |
| 781 | +
|
| 782 | + Args: |
| 783 | + key (uuid.UUID): The key of the attachment. |
| 784 | + folder_key (str | None): The key of the folder. Override the default one set in the SDK config. |
| 785 | + folder_path (str | None): The path of the folder. Override the default one set in the SDK config. |
| 786 | +
|
| 787 | + Returns: |
| 788 | + BlobFileAccessInfo: Object containing the blob storage URI and attachment name. |
| 789 | +
|
| 790 | + Raises: |
| 791 | + Exception: If the attachment is not found or the request fails. |
| 792 | +
|
| 793 | + Examples: |
| 794 | + ```python |
| 795 | + import asyncio |
| 796 | + from uipath.platform import UiPath |
| 797 | +
|
| 798 | + client = UiPath() |
| 799 | +
|
| 800 | + async def main(): |
| 801 | + info = await client.attachments.get_blob_file_access_uri_async( |
| 802 | + key=uuid.UUID("123e4567-e89b-12d3-a456-426614174000") |
| 803 | + ) |
| 804 | + print(f"Attachment ID: {info.id}") |
| 805 | + print(f"Blob URI: {info.uri}") |
| 806 | + print(f"File name: {info.name}") |
| 807 | + ``` |
| 808 | + """ |
| 809 | + spec = self._retrieve_download_uri_spec( |
| 810 | + key=key, |
| 811 | + folder_key=folder_key, |
| 812 | + folder_path=folder_path, |
| 813 | + ) |
| 814 | + |
| 815 | + result = ( |
| 816 | + await self.request_async( |
| 817 | + spec.method, |
| 818 | + url=spec.endpoint, |
| 819 | + params=spec.params, |
| 820 | + headers=spec.headers, |
| 821 | + ) |
| 822 | + ).json() |
| 823 | + |
| 824 | + return BlobFileAccessInfo( |
| 825 | + id=key, |
| 826 | + uri=result["BlobFileAccess"]["Uri"], |
| 827 | + name=result["Name"], |
| 828 | + ) |
| 829 | + |
712 | 830 | @traced(name="attachments_delete", run_type="uipath") |
713 | 831 | def delete( |
714 | 832 | self, |
|
0 commit comments