Sha256: 41607f76f47e6becdbc8e37013588db2ab5e367f158dbe894bbc3b628e3ef4c4

Contents?: true

Size: 698 Bytes

Versions: 2

Compression:

Stored size: 698 Bytes

Contents

class PresignedPostsController < ApplicationController
  def new
    @post = Post.new
  end

  def create
    @post = Post.new(params.require(:post).permit(:title, :document_cache_id))

    if @post.save
      redirect_to [:normal, @post]
    else
      render :new
    end
  end

  def upload
    if params[:token] == "xyz123"
      if params[:file].size < 100
        File.open(File.join(Defile.backends["limited_cache"].directory, params[:id]), "wb") do |file|
          file.write(params[:file].read)
        end
        render text: "token accepted"
      else
        render text: "too large", status: 413
      end
    else
      render text: "token rejected", status: 403
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
defile-0.2.1 spec/defile/test_app/app/controllers/presigned_posts_controller.rb
defile-0.2.0 spec/defile/test_app/app/controllers/presigned_posts_controller.rb