Closed padhug closed 8 years ago
I managed to post server from dropzone.js events manually.
@padhug Can you explain your way? I have been problem with dropzone in this gem. Thank you very much.
Hi, We can use dropzone.js events to post server, this should work from your application.js
Dropzone.autoDiscover = false; // or disable for specific dropzone: //Dropzone.options.myDropzone = false;
$(function() { // Now that the DOM is fully loaded, create the dropzone, and setup the // event listeners var myDropzone = new Dropzone("#s3-uploader");
//This success event runs after successful uploads to s3 myDropzone.on("success", function(file, response) { /* Maybe display some more file information on your page */
console.log("added");
var xmlDoc = $.parseXML( response );
var $xml = $( xmlDoc );
var $title = $xml.find( "Location" );
$.ajax({
url: '/projects.js',
type: "POST", // type should be POST
data: { project: { import_file: $title.text(), name: file.name} }, // send the project object
success: function(response){
},
error: function(response) {
}
});
}); })
There is plenty of event functions available from dropzone.js which we can use, pls check their docs.
Thank you for your reply soon :heart_eyes:
In my case, when i used dropzone
, i lost unique_id
of files. I need unique_id
to make s3_directory.
Maybe i can't use dropzone
in my project.
Sorry for inconvenience. Have a nice day!
When I tried to upload more than 5 images and maxFiles is set to 8, I can't get any success callback, but it works fine with less than 5 images, This issue aeries with Amazon S3 bucket.
Hi, It's working fine if I sent file with input file selector. When I start using dropzone.js I'm getting 201 from amazon s3, but couldn't figure why it's not posting back to server, i tried manually adding callback_url in dropzone configuration as well.
This is my code now.
<%= s3_uploader_form callback_url: projects_path, callback_param: "project[import_file]", max_file_size: 5.megabytes, id: "s3-uploader", data: {:key => :val} do %>
<%= hidden_field_tag "Content-Type", ""%>
<% end %>