python - 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
解决方案
数据 = base64.b64decode(file.FileAttachment)
推荐阅读
- sql - 如何组合聚合、连接和分组依据?
- javascript - 在 ajax 成功运行 table.setData 但未加载数据
- java - 我无法在主类中获取我的 JPanel 的背景颜色
- java - 关于读取为字符串的两个编号变量的字符串拆分
- python - 在python中使用mrjob查找收入最多的前3个城市
- php - 无法获取表单以向 PHP 页面提交信息
- c++ - 具有一个元素的 initializer_list
- python - 从 InlineKeyboardButton 单击 URL 后删除键盘
- javascript - 如何用图像填充 html5 画布网格方块?
- javascript - 无法在给定的文件扩展名中有效地找到文件的文件扩展名