我需要为Apple通用链接发送具有特定内容类型(application/pkcs7-mime
)的文件。 我使用rails的send_file
函数,并添加:type
作为参数, 但类型始终为text/plain
。使用send_file设置内容类型
这里是我的控制器:
class AppleController < ApplicationController
def download_app_site_association
send_file "#{Rails.root}/public/apple-app-site-association", {:filename => "apple-app-site-association", :type => "application/pkcs7-mime" , :x_sendfile => true}
end
end
我也尝试添加这样的:
send_file "#{Rails.root}/public/apple-app-site-association", :filename => "apple-app-site-association", :type => "application/pkcs7-mime" , :x_sendfile => true
和手动设置它像这样:
response.headers["Content-type"] = "application/pkcs7-mime"
send_file "#{Rails.root}/public/apple-app-site-association", :filename => "apple-app-site-association", :x_sendfile => true
谁能给我解释一下为什么这不起作用?
是的,但如我的问题所写,它不适用于我。 – Shrolox
不,它没有被注册,但我在我的代码中发现了问题,并会发布答案。无论如何感谢您的帮助 – Shrolox