OSError:[Errno 30]Zapier尝试用Python代码打开PDF时使用只读文件系统

2024-05-15 01:53:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在Zapier中创建一个zap,搜索特定的客户机,然后在Google Drive中找到他们的文件夹。然后它从Google Drive文件夹中获取一个PDF文档,并上传到HelloSign以发送到客户端。我正在使用Zapier step的代码从Google Drive中提取PDF并上传到HelloSign

Zapier step的代码中的代码在我的本地机器上运行,但是当我尝试在Zapier中运行它时,我会为我尝试创建的文档获取“OSError:[Errno 30]只读文件系统”,这样我就可以读取包含“with open('Test.PDF','wb')as f”的行的PDF。从读取another comment可以看出,这似乎是由于Zapier权限不允许在其系统上创建文件造成的。出错的代码块非常简单

output = {'status_code' : ''}

key = 'xxxxxxxx'

url = 'https://' + key + ':@api.hellosign.com/v3/signature_request/send'

response = requests.get(input['pdf'])
with open('Test.pdf','wb') as f:
    pdf = f.write(response.content)

files = {
    'Doc' : pdf
}

param = {
    'test_mode' : 1,
    'title' : "Test from HelloSign",
    'subject' : "Doc Ready",
    'message' : 'Hi! Please sign the attached doc.',
    'signing_redirect_url' : 'https://www.google.com/',
    'signers[0][name]' : input['name'],
    'signers[0][email_address]' : input['email']
    }

r = requests.post(url=url,files = files, params=param)

output['status_code'] = r.status_code

如果不使用open()阅读PDF,那么我可以将PDF传递给HelloSign发送,还有什么其他选择


Tags: 代码test文件夹urlinputpdfstatusgoogle
1条回答
网友
1楼 · 发布于 2024-05-15 01:53:03

这应该行得通

output = {'status_code' : ''}

key = 'xxxxxxxx'

url = 'https://' + key + ':@api.hellosign.com/v3/signature_request/send'

response = requests.get(input['pdf'])

files = {
    'file' : response.content
}

param = {
    'test_mode' : 1,
    'title' : "Test from HelloSign",
    'subject' : "Doc Ready",
    'message' : 'Hi! Please sign the attached doc.',
    'signing_redirect_url' : 'https://www.google.com/',
    'signers[0][name]' : input['name'],
    'signers[0][email_address]' : input['email']
    }

r = requests.post(url=url,files = files, params=param)

output['status_code'] = r.status_code

相关问题 更多 >

    热门问题