我需要爲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