-2

Please give me code example for override any method of uploadifive.

Here i have putted my js code, please have your look. i want to check duplicate file from backend. I have already method in controller.

If you give any sample for how i can override method then i can try ahead.

$('#file_upload').uploadifive({
  'auto'                : true,
  'buttonText'          : 'Select File',
  'checkScript'         : false,
  'queueSizeLimit'      : 10,
  'fileSizeLimit'       : 10737418240,
  'dnd'                 : false,
  'multi'               : true,
  'removeCompleted'     : true,
  'queueID'             : 'queue',
  'simUploadLimit'      : 30,
  'uploadLimit'         : 30,
  'overrideEvents'      : ['onProgress'],
  'uploadScript'        : '/files/pending',
  // Triggered for each file that is added to the queue
  'onAddQueueItem'   : function(file) {
    console.log(file.name + "file that is added to the queue");
    var folder = files.currentItemData();
    this.data('uploadifive').settings.formData = {
                          'timestamp'                     : current_date_time(),
                          'authenticity_token'            : token(),
                          'attachment[folder_id]'         : folder.id,
                          'attachment[context_code]'      : current_context_code(),
                          'attachment[language]'          : uploadifive_language_code(),
                          'success_action_status'         : "201",
                        //'attachment[duplicate_handling]': file.duplicate_handling,
                                                  };
  },
  // Triggered when a file is cancelled or removed from the queue
  'onCancel'         : function() {},
  // Triggered when the server is checked for an existing file
  'onCheck'          : function() {},
  // Triggered during the clearQueue function
  'onClearQueue'     : function() {},
  // Triggered when files are dropped into the file queue
  'onDrop'           : function() {},
  // Triggered when an error occurs
  'onError'          : function(file, fileType, data) {},
  // Triggered if the HTML5 File API is not supported by the browser
  'onFallback'       : function() {},
  // Triggered when UploadiFive if initialized
  'onInit'            : function() {},
  // Triggered once when an upload queue is done
  'onQueueComplete'  : function(file, data) {},
  // Triggered during each progress update of an upload
  'onProgress'   : function(file, e) {
    if (e.lengthComputable) {
      var percent = Math.round((e.loaded / e.total) * 100);
    }
    $('.uploadifive-queue-item').find('.fileinfo').html(' - ' + percent + '%');
    $('.uploadifive-queue-item').find('.progress-bar').css('width', percent + '%');
  },
  // Triggered once when files are selected from a dialog box
  'onSelect'          : function(file) {
    console.log(file.queued + ' files were added to the queue.');
    return;
  },
  // Triggered when an upload queue is started
  'onUpload'          : function(file) {
    console.log(file + ' files will be uploaded.');
    file_select_done();
  },
  // Triggered when a file is successfully uploaded
  'onUploadComplete'  : function(file, data) {
    res_data = JSON.parse(data);
    $.ajaxJSON(res_data.success_url,'GET',{"authenticity_token" : authenticity_token},function(data) {
      if (data && data["attachment"]){
        var file_id = data["attachment"]["id"];
        var file_name = data["attachment"]["display_name"];
        generate_li(file_name, file_id);
        qutaUpdate();
      }
    });
    console.log('The file ' + file.name + ' uploaded successfully.');
  },
  // Triggered for each file being uploaded
  'onUploadFile'      : function(file) {
    console.log('The file ' + file.name + ' is being uploaded.');
  }
});});
umishra
  • 390
  • 2
  • 14
  • Please give us a code example of what you've tried yet, and what failed. – Thomas Jul 30 '16 at 17:08
  • >> Now you can see, i have putted my js code, please have your look. i want to check duplicate file from backend. I have already method in controller. >> If you give any sample for how i can override method then i can try ahead. – umishra Jul 30 '16 at 17:18

1 Answers1

0

I found answer of my above question: :)

$('#file_upload').uploadifive({ 
    'overrideEvents'      : ['onProgress','onCheck'],
});

I putted uploadifive method in array and now all my code calling here not uploadifive's code.

Thanks!

umishra
  • 390
  • 2
  • 14