私はRuby on Railsを使用して単純なレストAPIサーバーを作成しました。ファイルシステムに置かれたRoRセーブ本体
put 'dreceiver/*other', to: 'myapps#update'
マイコントローラ:
class MyAppsController < ApplicationController
protect_from_forgery with: :null_session
# PUT
# Expected Parameters: {"other"=>"api/1.0/file/abc123"}
def update
#Need to grab last part of path sent in:
if params[:other] =~ /api\/1.0\/file\/.*/
batchid = params[:other].split('/').last
else
batchid = nil
end
unless batchid.nil?
render :text => '', :status => 201
else
render :text => '', :status => 401
end
return
end
end
私の問題:私はgzipファイルを期待し、私は私のroute.rbに私が必要myappというのコントローラーのupdateメソッドにパス全体を送信するこれを、追加しましたPUT要求の本文に送信される。私はそれをファイルシステムに保存する必要があります。私はpaperclipを使用してdbに格納する例をたくさん見ていますが、実際にはいくつかのクライアントコードをテストするだけです。ファイル。あなたの助けを前もってありがとう。
私はrequest.raw_postを探していました。一度それを得たら、私はFile.openを使ってそれをファイルに保存しました。 – RosyRuby