Sending file path to be uploaded in json

Hello,

Hello,

First of all thanks for the great tool. I have just started using shrine and trying to figure things out. I set it up in a ror backend application and I have the upload working properly, however i was wondering is there a possible way to do a simple post request for example to the upload endpoint as json? Maybe an example would be more clear. Something like Post /uploads and the json is something like { file: ‘path/of/image/to/be/uploaded’} . Where it gets the file path from the json and does the upload ?

Thank you

There isn’t anything like that out-of-the-box, but it should be straightforward to create your own endpoint. For example:

class UploadsController < ApplicationController
  def create
    file = File.open(params[:file], "rb")
    uploaded_file = FileUploader.upload(file, :cache)
    render json: uploaded_file.as_json
  end
end