首页 > 代码库 > grape 图片api

grape 图片api

 desc "Update image"
  params do
    requires :id,:type =>String,:desc =>"ID."
    requires :image,:type =>Rack::Multipart::UploadedFile,:desc =>"Image file."end
  post :image do
    new_file =ActionDispatch::Http::UploadedFile.new(params[:image])
    object =SomeObject.find(params[:id])
    object.image = new_file
    object.save
  end


链接地址 http://stackoverflow.com/questions/14067163/uploading-file-with-grape-and-paperclip