从 s3 代理 pdf 并将其内联渲染
Proxy pdf from s3 and render it out inline
我正在使用蜻蜓来处理我的附件,并使用 s3 来存储资产。
我知道我可以直接从 s3 提供服务,但我的客户已锁定互联网访问权限,因此无法访问它们。所以我需要做的是通过我的域代理图像。
data = open(@training_doc.upload.remote_url).read
send_data data, :filename => @training_doc.upload.name
这就是我所拥有的,但它不允许我将其内联呈现(在其自身的选项卡中),而是下载它,这并不理想。
我知道我可以这样做以内联呈现它,但这不是代理
redirect_to @training_doc.upload.remote_url(:expires => 2.hours.from_now, :query => {'response-content-disposition' => 'inline'})
我知道在 rails 中你可以使用 send_file 但这只有当你在普通文件系统中有它时才有效
他们还有其他方法/方式来实现这个目标吗?
send_data
方法有一个disposition
选项可以设置为inline
:
data = open(@training_doc.upload.remote_url).read
send_data(data,
:filename => @training_doc.upload.name,
:type => 'application/pdf',
:disposition => 'inline'
)
我正在使用蜻蜓来处理我的附件,并使用 s3 来存储资产。
我知道我可以直接从 s3 提供服务,但我的客户已锁定互联网访问权限,因此无法访问它们。所以我需要做的是通过我的域代理图像。
data = open(@training_doc.upload.remote_url).read
send_data data, :filename => @training_doc.upload.name
这就是我所拥有的,但它不允许我将其内联呈现(在其自身的选项卡中),而是下载它,这并不理想。
我知道我可以这样做以内联呈现它,但这不是代理
redirect_to @training_doc.upload.remote_url(:expires => 2.hours.from_now, :query => {'response-content-disposition' => 'inline'})
我知道在 rails 中你可以使用 send_file 但这只有当你在普通文件系统中有它时才有效
他们还有其他方法/方式来实现这个目标吗?
send_data
方法有一个disposition
选项可以设置为inline
:
data = open(@training_doc.upload.remote_url).read
send_data(data,
:filename => @training_doc.upload.name,
:type => 'application/pdf',
:disposition => 'inline'
)