<commit_before>class Adapt::AttachmentsController < ApplicationController
  # ----------------------------------------------------------------------------
  # Authorization and other filtering.
  # ----------------------------------------------------------------------------

  # -- find referenced resources before performing authorization
  before_authorization_filter :find_attachment

  # -- declare access permissions via the 'verboten' plugin
  permit :download, :if => :may_view

  private

  # Finds the attachment with id specified in the request and the study it
  # belongs to.
  def find_attachment
    @attachment = Adapt::Attachment.find_by_id(params[:id])
    @study = @attachment.study if @attachment
  end

  # Whether the current user may view the referenced study.
  def may_view
    @study and @study.can_be_viewed_by current_user
  end

  # ----------------------------------------------------------------------------
  # Actions this controller provides.
  # ----------------------------------------------------------------------------
  public

  # This custom action provides a file download for the referenced attachment.
  def download
    use_xsendfile = false # use in production when it's working on our server

    send_file(@attachment.stored_path,
              :filename => @attachment.name,
              :disposition => "attachment",
              :stream => true,
              :buffer_size => 1024 * 1024,
              :x_sendfile => use_xsendfile)
  end
end<commit_msg>Removed the :x_sendfile option from the send_file() call in attachments controller.<commit_after>class Adapt::AttachmentsController < ApplicationController
  # ----------------------------------------------------------------------------
  # Authorization and other filtering.
  # ----------------------------------------------------------------------------

  # -- find referenced resources before performing authorization
  before_authorization_filter :find_attachment

  # -- declare access permissions via the 'verboten' plugin
  permit :download, :if => :may_view

  private

  # Finds the attachment with id specified in the request and the study it
  # belongs to.
  def find_attachment
    @attachment = Adapt::Attachment.find_by_id(params[:id])
    @study = @attachment.study if @attachment
  end

  # Whether the current user may view the referenced study.
  def may_view
    @study and @study.can_be_viewed_by current_user
  end

  # ----------------------------------------------------------------------------
  # Actions this controller provides.
  # ----------------------------------------------------------------------------
  public

  # This custom action provides a file download for the referenced attachment.
  def download
    send_file(@attachment.stored_path,
              :filename => @attachment.name,
              :disposition => "attachment",
              :stream => true,
              :buffer_size => 1024 * 1024)
  end
end
{'fraction_non_alphanumeric': 0.2622342220722241, 'fraction_numerical': 0.005399932500843739, 'mean_word_length': 1.5225531914893617, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3009962', 'n_tokens_mistral': 680, 'n_tokens_neox': 626, 'n_words': 216}