Class: Glib::GlibDirectUploadsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/glib/glib_direct_uploads_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/glib/glib_direct_uploads_controller.rb', line 20

def create
  blob = ActiveStorage::Blob.new # generate blob key
  if blob_args[:prefix].present?
    blob.key = "#{blob_args[:prefix]}/#{blob.key}"
  end
  blob.assign_attributes(**blob_args.except(:tagging, :prefix))
  blob.save!

  if blob.service.instance_of?(::ActiveStorage::Service::GlibS3Service)
    blob.service.tagging = blob_args[:tagging]
  end

  render json: direct_upload_json(blob)
end