I'm using this Angular File Upload library for my uploading process.
It uploads perfectly okay using the same setup that is listed on that repo.
However, I have to have the files upload in a queue (1 file after another) as opposed to all the files uploading at the same time.
Example.
The example is using a fork repo and the requirement is that I use the one I listed.
Other options such as pause/cancel will also be needed.
Current setup:
Controller:
$scope.onFileSelect = function($files) {
for (var i = 0; i < $files.length; i++) {
//loop through files and put in an array
}
//execute upload function
$scope.start(files);
}
}
};
$scope.start = function(index) {
$upload.upload({
//upload clode
}).progress(function(evt) {
//Progress calculation
}).success(function(data, status, headers, config) {
//Success return
}).error(function(data, status, headers, config) {
console.log(data);
});
};
Try this, basically it just sends one file at a time until done. You could use $timeout if you would prefer a delay between sending each file:
$scope.onFileSelect = function($files) {
$scope.uploadList = $files;
$scope.uploadIndex = 0;
$scope.start(uploadIndex)
};
$scope.start = function() {
$upload.upload({
//upload code, send file
// Send file $scope.uploadList[$scope.uploadIndex];
}).progress(function(evt) {
//Progress calculation
}).success(function(data, status, headers, config) {
//Success return
$scope.uploadIndex++;
// Send the next file by calling ourselves
if (uploadIndex < uploadList.length)
$scope.start(); // Send the next one now - could be deferred a little by using $timeout
}).error(function(data, status, headers, config) {
console.log(data);
});
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With