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

tini8 · September 05, 2015 · Last by tini8 replied at September 05, 2015 · 2115 hits

在 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
)

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

You need to Sign in before reply, if you don't have an account, please Sign up first.