Skip to Content Skip to Search
Methods
D
S

Constants

DISPLAY_DOWNLOAD = "download"
 
DISPLAY_INLINE = "inline"
 
DISPLAY_POPUP = "popup"
 

Instance Public methods

download_file()

# File engines/member/app/controllers/member/content_controller.rb, line 21
def download_file
  @file = DB::ContentFile.friendly.find(content_params[:id])

  if member_can_view?(@file)
    display = (@file.viewing_preference == "browser") ? "inline" : "attachment"
    record_analytics("views", @file) if display == "attachment" && current_member
    disposition = "#{display}; filename=\"#{@file.filename}\""
    url = @file.attachment.url(
      response_content_disposition: disposition,
      response_content_type: @file.mime_type, expires_in: 5 * 60
    )
    redirect_to url
  # site_owner without ommiting the cmsbe because we want it to
  # not be able to download the file directly if is not on ss
  elsif current_member || site_owner
    session[:protected] = {content: content_params[:id], direct_download: true}
    redirect_to all_plans_path
  else
    redirect_to "/404"
  end
end

show()

# File engines/member/app/controllers/member/content_controller.rb, line 7
def show
  @content = DB::ContentLink.friendly.find(content_params[:public_id])

  if @content
    js_redirect_to(
      @content.site.widget_url(
        main_app.widget_content_disposition_path(@content, display_mode)
      )
    )
  else
    render file: "#{Rails.root}/public/404.html", status: "404"
  end
end