Class: S3Relay::UploadsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/s3_relay/uploads_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/s3_relay/uploads_controller.rb', line 10

def create
  @upload = S3Relay::Upload.new(upload_attrs)

  if @upload.save
    data = {
      private_url: @upload.private_url,
      parent_type: @upload.parent_type,
      parent_id: @upload.parent_id,
      user_id: user_attrs[:user_id]
    }
    render json: data, status: 201
  else
    render json: { errors: @upload.errors }, status: 422
  end
end

#newObject



6
7
8
# File 'app/controllers/s3_relay/uploads_controller.rb', line 6

def new
  render json: S3Relay::UploadPresigner.new.form_data
end