aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/active_storage/direct_uploads_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/active_storage/direct_uploads_controller.rb')
-rw-r--r--app/controllers/active_storage/direct_uploads_controller.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/controllers/active_storage/direct_uploads_controller.rb b/app/controllers/active_storage/direct_uploads_controller.rb
new file mode 100644
index 0000000000..dccd864e8d
--- /dev/null
+++ b/app/controllers/active_storage/direct_uploads_controller.rb
@@ -0,0 +1,11 @@
+class ActiveStorage::DirectUploadsController < ActionController::Base
+ def create
+ blob = ActiveStorage::Blob.create_before_direct_upload!(blob_args)
+ render json: { url: blob.url_for_direct_upload, sgid: blob.to_sgid.to_param }
+ end
+
+ private
+ def blob_args
+ params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type, :metadata).to_h.symbolize_keys
+ end
+end