【问题标题】:OSError: [Errno 30] Read-only file system when trying to open PDF in Python Code by ZapierOSError:[Errno 30] 尝试在 Zapier 的 Python 代码中打开 PDF 时出现只读文件系统
【发布时间】:2021-07-13 23:35:16
【问题描述】:

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

Zapier 步骤中的代码可以在我的本地计算机上运行,​​但是当我尝试在 Zapier 中运行它时,我得到我正在尝试的文档的“OSError: [Errno 30] Read-only file system”创建以便我可以阅读具有“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 以发送?

【问题讨论】:

    标签: python zapier


    【解决方案1】:

    这应该可以工作

    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
    

    【讨论】:

    • 太棒了,非常感谢!我想我不需要实际打开文档即可将其发送到下一个服务。
    猜你喜欢
    • 2018-07-01
    • 2020-05-19
    • 2021-06-19
    • 2022-11-23
    • 2021-11-19
    • 2018-10-05
    • 2022-06-23
    • 2020-12-03
    • 2020-11-15
    相关资源
    最近更新 更多