From 888cf202aed50dddd3bb2bc28117e91dc465924a Mon Sep 17 00:00:00 2001 From: bekzod Date: Wed, 3 Apr 2019 17:05:12 +0500 Subject: [PATCH] pass file to `target` function --- resumable.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resumable.js b/resumable.js index cba0ed4a..69fd37f9 100644 --- a/resumable.js +++ b/resumable.js @@ -116,7 +116,7 @@ } }; $.indexOf = function(array, obj) { - if (array.indexOf) { return array.indexOf(obj); } + if (array.indexOf) { return array.indexOf(obj); } for (var i = 0; i < array.length; i++) { if (array[i] === obj) { return i; } } @@ -198,7 +198,7 @@ return (size/1024.0/1024.0/1024.0).toFixed(1) + ' GB'; } }, - getTarget:function(request, params){ + getTarget:function(request, params, file){ var target = $.getOpt('target'); if (request === 'test' && $.getOpt('testTarget')) { @@ -206,7 +206,7 @@ } if (typeof target === 'function') { - return target(params); + return target(params, file); } var separator = target.indexOf('?') < 0 ? '?' : '&'; @@ -739,7 +739,7 @@ }) ); // Append the relevant chunk and send it - $.xhr.open($.getOpt('testMethod'), $h.getTarget('test', params)); + $.xhr.open($.getOpt('testMethod'), $h.getTarget('test', params, $.fileObj)); $.xhr.timeout = $.getOpt('xhrTimeout'); $.xhr.withCredentials = $.getOpt('withCredentials'); // Add data from header options @@ -871,7 +871,7 @@ } } - var target = $h.getTarget('upload', params); + var target = $h.getTarget('upload', params, $.fileObj); var method = $.getOpt('uploadMethod'); $.xhr.open(method, target);