Rails send_file 如果是图片的时候可不可以不下载直接在浏览器中显示?

tini8 · 2015年09月05日 · 最后由 tini8 回复于 2015年09月05日 · 2115 次阅读

在 controller 中是这样的:

response.headers['Cache-Control'] = 'public, max-age=2592000'
response.headers['Content-type'] = 'image/jpeg'
send_file(
    filepath,
    :filename => @attachment.name,
    :type => @attachment.content_type
)

我希望在附件是图片的时候,打开这个网址,直接在浏览器中显示图片,而不是像其它文件一样直接下载下来

需要 登录 后方可回复, 如果你还没有账号请 注册新账号