1

Amazon S3 サービスの支払いを避けるために、1 つのドロップボックス アカウントから古い試験 (.pdf) をアップロードおよびダウンロードするために、paperclip、dropbox、および paperclipdropbox の gem を使用しています。次のコントローラ メソッドを使用して、問題なくファイルをアカウントにアップロードできます。

def upload_exam
  if params[:document]
    @exam = Exam.new(:course_id => params[:course], :user_id => current_user.id, 
    :professor => params[:professor], :term => params[:term], 
    :document => params[:document], :description => params[:description])
  respond_to do |format|
  if @exam.save
    format.html { redirect_to test_bank_path, notice: 'Exam was successfully uploaded.' }
  else
    format.html { render action: "upload_exam" }
  end
end

ファイルをダウンロードするために、download_exam コントローラーのアプリケーションのパブリック ディレクトリからペーパークリップ ファイルを送信するのと同じ send_file メソッドを使用しています。

send_file @exam.document.path, :filename => @exam.document_file_name,
:type => @exam.document_content_type, :disposition => "attachment"

しかし、これはエラーを実行します

Cannot read file /documents/documents/18/original/ASCE_7-05_Chapter_3.pdf

私のアプリケーションはパブリック フォルダーでファイルを検索していると思いますが、私の調査ではドロップボックス フォルダーからダウンロードする方法が見つかりませんでした。経験者の方、助けてください!!

4

0 に答える 0