【发布时间】:2018-06-17 00:21:03
【问题描述】:
我的应用程序中有用于文档(pdf、doc)的 Paperclip gem。我需要通过 post 请求将文档传递给其他第三方应用程序。
我尝试通过 Base64 转换回形针附件,但它抛出错误: 没有将 Tempfile 隐式转换为 String
我是这样做的:
# get url from the paperclip file
url = document.doc.url # https://s3-ap-southeast-1.amazonaws.com/xx-eng/documents/xx/000/000/xx/original/doc.pdf
file_data = open(url)
# Encode the bytes to base64 - this line throw error
base_64_file = Base64.encode64(file_data)
您对如何避免 Tempfile 错误有什么建议吗?
【问题讨论】:
标签: ruby-on-rails ruby paperclip