ncuesta / dropzonejs-rails

Spice your Rails apps with some Dropzone sugar!
http://rubygems.org/gems/dropzonejs-rails
MIT License
311 stars 56 forks source link

Big files upload twice ? #35

Closed Sashkan closed 7 years ago

Sashkan commented 8 years ago

I'm using dropzone to handle uploads in a rails app. It works just fine with small files, but unfortunately, when it comes to files > 300MB, things go sour: The upload animation freezes (nevers reaches its 'complete' state), user have to reload the page, only to see that his file uploaded twice.

Is there a way to prevent this behaviour ?

ncuesta commented 8 years ago

Hi @Sashkan, what is causing that may depend either on your setup and/or your specific implementation of the uploads handling process. Also, you may want to check enyo/dropzone#95, as that's the actual repo for the JS library, this is just a wrapper gem.

Anyhow, if you could provide me with more info, I might be able to see if there's anything suspicious on the Ruby side.

Sashkan commented 8 years ago

Sure :)

Here are the basics: First, the Dropzone call:

  var myDropzone = new Dropzone("#resources-dropzone", {
    url: "<%= upload_resources_path %>",
    maxFilesize: 1000
  });

  myDropzone.on("complete", function(file) {
    location.reload();
  });

  $(document).ready(function() {
    var url = document.location.toString();
    if (url.match('#')) {
        $('.order-tabs a[href=#'+url.split('#')[1]+']').click();
    }
  });

All files are processed with the following rb function

  def upload_resources
    authorize(:brief, :upload_resources?)
    @path = upload_resources_path(Brief.find(params[:id]))
    @resource = Resource.new
    @resource.file = params[:file]
    @resource.uploader_id = current_user.id
    @resource.brief_id = params[:brief_id]
    if @resource.save
      flash[:notice] = t('resources.upload.done')
    else
      puts @resource.errors.full_messages
    end
    render :nothing => true
  end

Funny thing is, it only occurs when I try to upload huge files (Like, > 500MB)

ncuesta commented 8 years ago

@Sashkan and what do you get on the browser DevTools network/console panes? Do you see any JS error? Is the AJAX request stuck/unresponsive?

Sashkan commented 8 years ago

Nope, no errors. However, for some weird reason, I got absolutely no css/js upload progress animation (Though, I don't think it has anything t o do with the double-upload issue)

ncuesta commented 8 years ago

And have you tracked on the Ruby side if the request for those large files is being received twice? That would help on isolating on which side of the communication the problem is being raised.

ncuesta commented 7 years ago

Closing this out due to inactivity.