-
-
Notifications
You must be signed in to change notification settings - Fork 189
Upload integration
Miguel Michelson Martinez edited this page Sep 23, 2016
·
2 revisions
When you upload an image via Dante uploader, Dante will make a POST request to the server url defined in upload_url
option on Dante initialization.
So, your backend (php, ruby, etc) app will receive that POST request with the image data for the backend to handle the upload, that's up to the backend implementation. The only base requirement is that the backend returns the url of the uploaded file, so Dante will know that the url returned by your backend script is the url to be replaced in the tag on the interface.
It you can't control the backend response , then you can use the upload callback to handle the response in the client
Here is a simple example in ruby:
# Handle POST-request (Receive data, save the uploaded file and return url of upload image)
post "/upload_image" do
name = params['file'][:filename]
path = File.join(File.dirname(__FILE__), '/uploads/images', name)
File.open(path, "wb") do |f|
f.write(params['file'][:tempfile].read)
end
return "/uploads/images/#{name}"
end
-
upload_url
: default: /uploads.json -
upload_callback
default: empty, allows optional way to handle the server response when image is uploaded This is useful when you don't have control on the backend response. -
image_delete_callback
: default: none, returns the image data before deletion. use this if you want to destroy image from the server. -
image_caption_placeholder
default: "Type caption for image (optional)"