SHARE
TWEET

Untitled

a guest Oct 10th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def create
  2.     blob = ActiveStorage::Blob.create_after_upload!(
  3.           io: params[:file][0],
  4.           filename: params[:file][0].original_filename,
  5.           content_type: params[:file][0].content_type
  6.         )
  7.  
  8.     respond_to do |format|
  9.       format.json do
  10.         render json: {
  11.           "file": {
  12.             "thumb": "",
  13.             "url": url_for(blob),
  14.             "id": blob.id,
  15.             "title": blob.filename
  16.           }
  17.         }.to_json
  18.       end
  19.     end
  20.   end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top