Was trying to add authorization to the upload endpoint, following the controller here https://shrinerb.com/docs/plugins/upload_endpoint, but it seems not to be working… I’m using rails and shrine 3.2
If i add the following endpoint on routes.rb it works ok.
mount Shrine.upload_endpoint(:cache) => "/upload"
Nevetherless if i add a custom controller with authorization like this (with the same upload on the client)
match '/upload' => 'images#upload', via: :all
I’m getting the message “Upload Not Valid”
This is my controller
class ImagesController < ApplicationController def upload set_rack_response ImageUploader.upload_response(:cache, request.env) end private def set_rack_response((status, headers, body)) self.status = status self.headers.merge!(headers) self.response_body = body end end
Checking the method “get_multipart_upload” on upload_endpoint.rb it seems there is a validation where value needs to be a Hash. But the file is a hash only if it’s directly upload with the rack, when using rails this is a “ActionDispatch::Http::UploadedFile” object.
Could this be a bug or i’m using it in the wrong why?