hbp_service_client/storage_service/client.py
def download_file(self, path, target_path):
        '''Download a file from storage service to local disk.

        Existing files on the target path will be overwritten.
        The download is not recursive, as it only works on files.

        Args:
            path (str): The path of the entity to be downloaded. Must start with a '/'.

        Returns:
            None

        Raises:
            StorageArgumentException: Invalid arguments
            StorageForbiddenException: Server response code 403
            StorageNotFoundException: Server response code 404
            StorageException: other 400-600 error codes
        '''

        self.__validate_storage_path(path)
        entity = self.api_client.get_entity_by_query(path=path)
        if entity['entity_type'] != 'file':
            raise StorageArgumentException('Only file entities can be downloaded')

        signed_url = self.api_client.get_signed_url(entity['uuid'])
        response = self.api_client.download_signed_url(signed_url)

        with open(target_path, "wb") as output:
            for chunk in response.iter_content(chunk_size=1024):
                output.write(chunk)
def download_file(self, path, target_path):
        '''Download a file from storage service to local disk.

        Existing files on the target path will be overwritten.
        The download is not recursive, as it only works on files.

        Args:
            path (str): The path of the entity to be downloaded. Must start with a '/'.

        Returns:
            None

        Raises:
            StorageArgumentException: Invalid arguments
            StorageForbiddenException: Server response code 403
            StorageNotFoundException: Server response code 404
            StorageException: other 400-600 error codes
        '''

        self.__validate_storage_path(path)
        entity = self.api_client.get_entity_by_query(path=path)
        if entity['entity_type'] != 'file':
            raise StorageArgumentException('Only file entities can be downloaded')

        signed_url = self.api_client.get_signed_url(entity['uuid'])
        response = self.api_client.download_signed_url(signed_url)

        with open(target_path, "wb") as output:
            for chunk in response.iter_content(chunk_size=1024):
                output.write(chunk)
def download_file ( self , path , target_path ) : self . __validate_storage_path ( path ) entity = self . api_client . get_entity_by_query ( path = path ) if entity [ 'entity_type' ] != 'file' : raise StorageArgumentException ( 'Only file entities can be downloaded' ) signed_url = self . api_client . get_signed_url ( entity [ 'uuid' ] ) response = self . api_client . download_signed_url ( signed_url ) with open ( target_path , "wb" ) as output : for chunk in response . iter_content ( chunk_size = 1024 ) : output . write ( chunk )
Download a file from storage service to local disk.

        Existing files on the target path will be overwritten.
        The download is not recursive, as it only works on files.

        Args:
            path (str): The path of the entity to be downloaded. Must start with a '/'.

        Returns:
            None

        Raises:
            StorageArgumentException: Invalid arguments
            StorageForbiddenException: Server response code 403
            StorageNotFoundException: Server response code 404
            StorageException: other 400-600 error codes
Download a file from storage service to local disk .