我正在使用beatbox和python将文档上传到Salesforce,文件是正确附加的,但是文件中包含的数据完全损坏。
def Send_File():
import beatbox
svc = beatbox.Client() # instantiate the object
svc.login(login1, pw1) # login using your sf credentials
update_dict = {
'type':'Attachment',
'ParentId': accountid,
'Name': 'untitled.txt',
'body':'/Users/My_Files/untitled.txt',
}
results2 = svc.create(update_dict)
print results2产出如下:
00Pi0000005ek6gEAAtrue因此,事情进展顺利,但当我转到salesforce记录00Pi0000005ek6gEAA并查看文件内容时,文件的内容如下:
˝KÆœ Wøä ï‡Îä˜øHÅCj÷øaÎ0j∑ø∫{b∂Wù我不知道是什么引起了这个问题,我也找不到其他人发生这种事情的任何情况
链接到 关于上载的SFDC文档
发布于 2014-04-26 15:56:47
字典中的'body‘值应该是文件的base64编码的内容,而不是文件名。您需要自己读取文件内容并对其进行编码。例如:
body = ""
with open("/Users/My_Files/untitled.txt", "rb") as f:
body = f.read().encode("base64")
update_dict = {
'type' : 'Attachement'
'ParentId' : accountId,
'Name' : 'untitled.txt',
'Body' : body }
...关于附件的文档
https://stackoverflow.com/questions/23312509
复制相似问题