首页 > 解决方案 > Thycotic WebService DownloadFileAttachementByItemId 方法

问题描述

Thycotic 用户可以访问 Web 服务https://thycotic.force.com/support/s/article/Using-Web-Services-with-Windows-Authentication-PowerShell

我可以下载该文件,但我无法读取该文件的内容:

file = client.service.DownloadFileAttachmentByItemId(authtoken, secret.SecretSummaries.SecretSummary[0].SecretId,secretvalue.Secret.Items.SecretItem[1].Id)

这成功并返回:

       (FileDownloadResult){
         Errors = ""
         FileAttachment = "YAAiAAJBEqww"
           FileName = "nonesense.txt"
       }

如果我尝试读取返回的文件

         with open(file,'r') as file_handle:
                for line in file_handle:
                  print line

我收到此错误:

         TypeError: coercing to Unicode: need string or buffer, instance found

标签: python

解决方案


数据 = base64.b64decode(file.FileAttachment)


推荐阅读