FIX: keep to old attachment route

This commit is contained in:
Régis Hanol 2015-05-20 14:55:42 +02:00
parent 0bd6d79459
commit b44488b618
2 changed files with 3 additions and 1 deletions

View File

@ -29,7 +29,7 @@ class UploadsController < ApplicationController
return render_404 unless Discourse.store.internal?
return render_404 if SiteSetting.prevent_anons_from_downloading_files && current_user.nil?
if upload = Upload.find_by(sha1: params[:sha])
if upload = Upload.find_by(sha1: params[:sha]) || Upload.find_by(id: params[:id], url: request.fullpath)
opts = { filename: upload.original_filename }
opts[:disposition] = 'inline' if params[:inline]
send_file(Discourse.store.path_for(upload), opts)

View File

@ -295,6 +295,8 @@ Discourse::Application.routes.draw do
get "uploads/:site/:sha" => "uploads#show", constraints: { site: /\w+/, sha: /[a-f0-9]{40}/ }
# used to download attachments
get "uploads/:site/original/:dir1/:dir2/:sha.:extension" => "uploads#show", constraints: { site: /\w+/, dir1: /[a-f0-9]/, dir2: /[a-f0-9]/, sha: /[a-f0-9]{40}/, extension: /\w{2,}/ }
# used to download attachments (old route)
get "uploads/:site/:id/:sha.:extension" => "uploads#show", constraints: { site: /\w+/, id: /\d+/, sha: /[a-f0-9]{15}/, extension: /\w{2,}/ }
get "posts" => "posts#latest"
get "posts/by_number/:topic_id/:post_number" => "posts#by_number"