利用代码块能力,可将任意内容生成二维码并存储于附件之中

分享  收藏
2 / 762
  1. 首先需要在服务器中扩展代码块的依赖库【详情参考:技术白皮书
  2. 需要扩展的有:qrcode、pilllow(两个库)
  3. 在工作流的代码块节点中输入以下代码
    import qrcode
    import base64
    from io import BytesIO
    code=input["code"]

img = qrcode.make(code)
output_buffer = BytesIO()
img.save(output_buffer,format='JPEG')
binary_data = output_buffer.getvalue()
base64 = base64.b64encode(binary_data)
base64String = str(base64,'utf-8')
output = {'strqr':base64String }

4.接着根据以下教程:附件上传之 Base64 模式,将生成的二维码(最终输出的是 base64)存入表单的附件中

【具体如下图所示】
414j3JcL9fek3l4L9La2dxfD47cIdSdYec7B0M3h3waN5P6gei3h9F1G6NfIbR3e.png