So I want to dynamically generate a MIDI file on a web request.Coming from the Java world, I expected something to the tune of
class MidisController < ApplicationController
before_filter :set_content_type
def set_content_type
@headers["Content-Type"] = "audio/midi; charset=utf-8"
end
def show
midi_data = get_midi_data
response.write(midi_data)
end
But the API says, stay away from the response object. 开发者_高级运维Any ideas ?
Look at the Rails docs for send_file or send_data. It handles all of the header requirements for you.
精彩评论