我想在电子邮件中提供跟踪图像。
该电子邮件将调用将返回图像的 sinatra 路由。
在 Rails 中,我会这样做:
send_data Base64.decode64("R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="), type: "image/gif", disposition: "inline"
Run Code Online (Sandbox Code Playgroud)
我将如何在 sinatra 中做到这一点?
get '/route' do
content_type 'image/gif'
Base64.decode64("R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
end
Run Code Online (Sandbox Code Playgroud)
如果你想设置处置,你可以这样做(例如):
headers 'Content-Disposition' => 'inline;filename="tracking.gif"'
Run Code Online (Sandbox Code Playgroud)
或者
attachment 'tracking.gif', 'inline'
Run Code Online (Sandbox Code Playgroud)