basecamp / thruster

MIT License
912 stars 31 forks source link

Set x-sendfile header in rails config #44

Closed npezza93 closed 1 month ago

npezza93 commented 1 month ago

Hey there!

Been messing around with some image stuff and found that out of the box x-sendfile wasnt being used. In a controller i have:

    send_file file.path,
      type: content_type || DEFAULT_SEND_FILE_TYPE,
      disposition: disposition || DEFAULT_SEND_FILE_DISPOSITION,
      file_name: params[:filename]

and then i put some bindings inside Rake::Sendfile and it never was getting called. I then set config.action_dispatch.x_sendfile_header = "X-Sendfile" in config/application.rb and it started getting hit. So this pr sets the header by default in a railtie so people dont have to set it.

But after setting this, rack sets the content length to 0 and the file never gets loaded. (im assuming thruster comes back through and does the download but doesnt seem to be). I've attached a screenshot of the network hoping that helps. Am I miss configuring something here to enable x-sendfile usage? I'll also note im doing this with the disk adapter of active storage if that matters.

Thanks!

image
npezza93 commented 1 month ago

Nevermind, didnt realize thruster works on a different port. Good to go here!