2016-11-28 83 views
0

我有一個生成png文件的API。Rails:apache提供服務時的資產404

用戶請求生成,並回復生成文件的路徑。

我這是怎麼生成的網址:

url_for(:controller => :anaction, :action => :download, :path => "#{@relative_dir}/face", :format => 'png' 

這一代產量,看起來一個URL,如:

http://0.0.0.0:3000/anaction/aging/download/%2FTMP_20161128204315_346482_695%2Fface.png 

應該由

def download 
    send_file "#{Rails.public_path}/#{params[:path]}.#{params[:format]}" 
    end 

處理根據 我的路線

get '/anaction/aging/download/:path' => 'mpsynthesizer_aging#download' 

它在我的開發環境中工作,在我的nginx服務器上,但在我的apache服務器上失敗。

我得到一個普通的Apache HTTP400錯誤,似乎請求永遠不會轉發到rails。

我用導軌4.2.6

是不是我誤解?

回答

0

我結束了使用

render body: IO.binread(result_file), content_type: "image/png"