Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if params[:image] && params[:image][:tempfile] && params[:image][:filename]
- begin
- token = "Bearer blahblahblah"
- file = params[:image][:tempfile]
- response = HTTParty.post("https://nameless-forest-80107.herokuapp.com/api/images", body: { image: file }, :headers => { "Authorization" => token} )
- data = JSON.parse(response.body)
- #make post
- current_user.profile_image_url = data["url"]
- current_user.save
- halt 200, {"message" => "Image updated"}.to_json
- rescue => e
- puts e.message
- halt 422, {message: "Unable to create image"}.to_json
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement